-
Notifications
You must be signed in to change notification settings - Fork 59
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
Enable out-of-order migrations by prefixing with timestamp instead of integer #65
Comments
Coming from Rails, your proposed solution is something I expected as well. But from experience the Rails approach has also caused a lot of pain in the past. One possible suggestion (YMMV) is to fix your process: one person is in charge of migrations, and he/she has to approve it. This way one person is responsible for the DB schema, and can vet issues before going into production. This person is also responsible for determining which migration should go in first, and assign numbers to the person. Not the painkiller though. Just a thought experiment in my head should my team actually scale. |
|
@ernsheong What pain are you referring to? I, too, come from Rails and have liked the timestamp based approach. But I've never worked with too big a projects. |
@haarts The pain happens when there are migration conflicts, which can happen from time to time in a project with multiple engineers. Rare but possible. Admittedly the single integer increment will definitely conflict more with multiple people on the same project. Can check out https://github.com/robinjoseph08/go-pg-migrations for an alternative. Has anyone tried, if using timestamps with this repo does it run migrations out of order? |
I'm also trying out the timestamp approach and works well here but there's a bug when executing |
I tried creating a migration on a previous date from the current version and the migration doesn't run. Yes, this library does support having a large number as an ID for a migration. But if 2 branches with different features add a migration, there shouldn't be any extra step when merging into master. In most cases these migrations won't conflict when altering the schema or seeding data). I know I come from the Rails world and thus I'm very opinionated in this case but I see the benefits. What I see as behaviour here is the following:
|
It looks like https://github.com/robinjoseph08/go-pg-migrations is working like that. But I kinda like the fact that you need to manually resolve conflicts when there are migrations with the same id - it sounds more bullet proof in theory, e.g. when migrations try to rename the same column. Such extra safety should be worth small annoyance it creates... |
Thank you @vmihailenco I had a look at it and changing from this solution to that solution was really easy. |
In team environment where everyone is working on their own branch, the integer-based migration approach breaks down as it causes collisions.
One solution is to prefix migrations with a timestamp instead of integer. The version table can keep track of the timestamp instead of the version number.
The text was updated successfully, but these errors were encountered: