migration file naming convention
Hi there. When working with a team on a project that involves database migrations, it's common to encounter conflicts with migration file names, especially if the naming convention involves sequential numbers like 00003_random_text. how do you cope with that? is there a way to contol generated file name to add timestamp? is it ok to have 2 migration file with the same index?
4 Replies
You can probably change the migration prefix to be timestamp via the Drizzle config file https://orm.drizzle.team/docs/kit-overview
Drizzle ORM - Overview
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
Your bigger problem is likely merging of the journal.json and snapshot.json files upon merging each team member's feature branch
Someone seems to share similar concerns here and got some answer: https://github.com/drizzle-team/drizzle-orm/discussions/1104
GitHub
Best way to deal with migration merge conflicts? · drizzle-team dr...
Hello! Sometimes team members will modify the DB schema on separate branches, resulting in conflicting journal.json and xxxx_snapshot.json. Editing these files by hand is quite tedious. What's ...
I agree that Drizzle really doesn't have a good happy path for big parallel team collaboration (but likely that's not Drizzle's fault - the tradeoff of using ORMs for migration managing is that it needs to keep a sequential history/ordering so Drizzle knows what have been merged and what order to migrate when on a brand new db).
If you search "merge conflicts" on this server, you will see many people with same questions on dealing with merge conflicts. The answer is either let CI generate migrations. Or do Git acrobatics like git rebase and then drop + re-generate your migrations so that the migrations history explicitly become sequential