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

Add beforeAll/afterAll events + file locking #397

Merged
merged 2 commits into from
Nov 24, 2020
Merged

Conversation

mmkal
Copy link
Contributor

@mmkal mmkal commented Nov 23, 2020

Follow-up to #394

This adds beforeAll and afterAll events. They run before the first and after the last migration respectively, for both up and down calls. This allows for locking functionality as requested in #144. Right now, there's a FileLocker class which uses the filesystem to implement a very basic locking mechanism. Adding actual database locking is more complex though, since every database system implements locks differently. I plan to use this to add locking to @slonik/migrator, since that's postgresql-only. It might be possible to add a SequelizeLocker class similar to FileLocker using transactions, but if that's difficult it could come in another follow-up. @papb have you use sequelize locks before?

@mmkal mmkal merged commit bdde73b into master Nov 24, 2020
@mmkal mmkal deleted the before-after-all branch November 24, 2020 00:23
@papb
Copy link
Member

papb commented Dec 3, 2020

Very nice! Great idea. As for using Sequelize transactions to lock the table, that should work, and shouldn't be too hard. I don't have time to try to do it though... Not now at least.

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

Successfully merging this pull request may close these issues.

None yet

2 participants