Repository navigation
Multiple Devs working on separate branches with migrations: How to stitch back together? #4299
Replies: 1 comment 2 replies
|
Hey @cotw-fabier 👋 This is a good question that we have observed multiple dev teams have been struggling with. We aim to write some guides around this soon to help out. But I'll try to give some answers directly here. In order to safely roll your database forward, the order of how migrations are applied is very important. Therefore any changes added MUST be added last, you should never patch the migration history, only append to it. In order to make it easier to detect if the migration history has changed during the time you developed your feature we added the migration_registry.txt. This file will always have collisions if someone else has merged a migration that is not present in your branch. When a collision is detected you should remove all migrations you have created in the branch and create a new one to correctly append to the history. Removing all migrations that are not part of the migration registry is currently a manual task, but I think we could introduce a command for that in the cli. Ideally a commit to main should contain a single migration. This allows you to test the effects of that migration in isolation before rolling the database forward further. |
Uh oh!
There was an error while loading. Please reload this page.
I am working with a small team of devs and we've been moving quite fast each taking various features which often require migrations. Since the migrations are time based a few times now we've had trouble stitching everything back together when we finally merge up our branches.
Since migrations run in order we keep missing various migrations since our local DB or dev instance online play some migrations but not others once they are merged in.
Any ideas on best practice on how to handle this kind of merging of migrations back together? Do we just stick with "play them back manually"? or is there a hidden serverpod feature I haven't discovered yet to help?
All reactions