-
Notifications
You must be signed in to change notification settings - Fork 1
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
Prevent migrations from running twice #30
Comments
Hi there, thank you for the kind words! I get your use case, and in fact we faced the same challenge. My solution was to have a dedicated lock entry in the database, which would prevent more than one migration running simultaneously. Once the migration is finished, the lock will be removed, the next instance would continue (simply with no further migrations executed), and so on. The code for that currently exists in our private code base, but I'd be fine with contributing it to this plugin. Let me have a look later today and get back here! |
@simplenotezy I've copied our solution (and added tests). If you already want to have a look, feel free :-) I'm on the run now, but I can release this to NPM tomorrow. |
That's really cool!! And thanks for prompt reply. I'll look into it. Just curious: where in your k8s setup do you run migrations? |
@simplenotezy I’ve pushed these changes to NPM as
Disappointing fact: We're not running on K8s at all! We “orchestrate” our nodes manually and via scripts, originally starting from one single container instance back then to now now several distributed across a cluster. To update containers we just pull them automatically from a registry, restart them, and upon container start, the migrations are being run. Dead simplea and boring, but reliable and sufficient for us 🙂 |
@qqilihq wow, that was awesome. Really quick! I tried, pulling it down, and then running the same migration in two seperate terminal windows, but I still do see my console log from the "up" appear twice. Do I need to configure something?
Ah well, as long as it works and you're happy with it - why fix it! 😊 Kubernetes is really fun though. |
You'll explicitly need to set the Let me know if this helps! |
@simplenotezy Any feedback? |
@qqilihq Very sorry for late response; been swamped lately. I haven't forgot about it and will test soon. |
First of all; thanks for great work put into this extension. Just what we needed!
Is there a way to prevent migrations from running twice?
If you have a migration job that takes a while to execute, and run migrate:up in a separate environment, it will re-run the existing (i.e. already running) migration.
E.g. when having a multi container setup in Kubernetes this feature to prevent migrations from running twice (i.e. before the other migration finished) would be helpful.
The text was updated successfully, but these errors were encountered: