-
Notifications
You must be signed in to change notification settings - Fork 15
Description
Firstly, thank you for this wonderful library! We've been happily using it for over 2 years.
I have a feature request. Sometimes we have multiple instances of our application start a the same time, and they all try to run the same DB migration. Suffice to say, only one instance is successful and the others often crash. Worst case scenario, they could interfere with each other and break the migration.
I was thinking it would be useful to have an option to lock the schema_migration table in order to avoid such issues (or even do it by default). This would be the order of operations:
- lock
schema_migration - select version from the DB
- plan migrations, apply migrations
- insert new version
- unlock
schema_migration
This way if multiple applications try to run migrations at the same time, only one will get the lock. After the migration completes, the other ones can then get the lock, select versions, and realize that there's nothing to migrate anymore.
I'm thinking of either implementing locking in our applications or contributing the feature here, but I don't know when I'll have the time to do it. Perhaps someone else would like to implement it? For reference, we're using the postgres driver.