db-migrate / db-migrate/pg

Grab an advisory lock for migration as per Heroku recommendations

Open
#23 0 comments 7 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
68
Forks
50
PR merge metrics
No merged PRs in 30d

Description

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!](https://www.bountysource.com/issues/49534554-grab-an-advisory-lock-for-migration-as-per-heroku-recommendations?utm_campaign=plugin&utm_content=tracker%2F14258523&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F14258523&utm_medium=issues&utm_source=github).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.