-
Notifications
You must be signed in to change notification settings - Fork 176
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
Locking migrations #88
Conversation
308eea3
to
21e1520
Compare
lib/runner.js
Outdated
.then(() => db.query(`COMMENT ON TABLE "${schema}"."${options.migrations_table}" IS '${lockName}'`)) | ||
.then(getCurrentLockName) | ||
.then(currentLockName => { | ||
if (currentLockName !== lockName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now when I'm looking on it. It is not 100% lock 🤦♂️
When some other lock
manages to run between first getCurrentLockName
and commenting on table, we will have two locks obtained...
lib/utils.js
Outdated
|
||
export const getMigrationTableSchema = options => options.migrations_schema || options.schema || 'public'; | ||
|
||
export const finallyPromise = block => [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately native Promise does not have finally
...
|
||
export const getMigrationTableSchema = options => options.migrations_schema || options.schema || 'public'; | ||
|
||
export const finallyPromise = func => [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately native Promise does not have finally
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fixes #72
I found several options:
UPDATE/INSERT INTO xxx WHERE lock IS NULL
) but I do not want to pollute schema with another table