Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grab an advisory lock for migration as per Heroku recommendations #23

Open
brabster opened this issue Sep 20, 2017 · 0 comments
Open

Grab an advisory lock for migration as per Heroku recommendations #23

brabster opened this issue Sep 20, 2017 · 0 comments

Comments

@brabster
Copy link

brabster commented Sep 20, 2017

Hi there,

I saw some advice on https://devcenter.heroku.com/articles/release-phase#design-considerations that suggests grabbing an "advisory lock" on the database before running a migration.

Basically, try SELECT pg_try_advisory_lock(migration); at the start of the transaction.

  • It if returns t then nothing currently has the lock, called 'migration', so proceed.
  • If not, fail the migration.
    The lock will be release when the transaction commits or rolls back.

I think that would be a one-line change in this module. Good idea?


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant