Multi-branch development

Hoping to get some discussion on this issue https://github.com/drizzle-team/drizzle-orm/issues/1221. How are people managing drizzle migrations when working with multiple team members? Ideally version numbers would be a timestamp so they don’t conflict.
GitHub
Issues · drizzle-team/drizzle-orm
Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅 - Issues · drizzle-team/drizzle-orm
3 Replies
oke
oke5mo ago
You can actually use timestamp instead of incremental number as the prefix for your SQL migration naming with the prefix option in the drizzle-kit file But version number being timestamp is not necessarily conflict-free. I agree that Drizzle really doesn't have a good happy path for big parallel team collaboration. But I can't really think of a solution. The tradeoff of using an ORM that can automatically generates migrations for you 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. Drizzle needs a linear/sequential history of migrations (recorded in the Drizzle meta.json and snapshot.json files) so that Drizzle knows which migrations have been applied, what is the current snapshot of the database so it knows which columns have changed, and which order do run migrations on a brand new database. So if team member generates migration parallel and use time-stamp so file name no overlap, they would still need to manually reconcile the meta.json and snapshot.json files so that Drizzle's history is still sequential, and the snapshot is correct -> Which leads to the expected merge conflicts
oke
oke5mo ago
If you search "merge conflicts" on this server, you will see many people with same questions on dealing with merge conflicts. The answer I have seen is either let CI generate migrations instead of developers. Or do Git acrobatics like git rebase and then drop + re-generate your migrations so that the migrations history become sequential again. Here are some Github discussion on potential workaround on this issue: 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 ...
jreynoldsdev
jreynoldsdevOP5mo ago
Appreciate the response! Looks like they may also have something in the works for the next version https://x.com/andrii_sherman/status/1928476200646709507?s=46&t=hVER0a1mlNvkwzpf_h3udw
Andrew Sherman 🇺🇦 (@andrii_sherman)
@GeorgeMayer @DrizzleORM yes, merge conflicts is something we are working on @_alexblokh made a full drizzle-kit rewrite to have a solid core to fix issues with merge conflicts and rollbacks. Which is the last thing before going v1 https://t.co/uOnOc9n68s
X

Did you find this page helpful?