When you generate a migration, three files are modified:
a new SQL file, called {ID}_{two or three random words}.sql, which describes the transformations to synchronize the database with the current state of the schema.
a snapshot file, called meta/{ID}_snapshot.json
and the journal file, listing off the migrations in order.
When two developers in separate branches create migrations simultaneously, files (2) and (3) will correctly result in conflicts, but file (1) will not. This means simple patterns like merge --theirs && regenerate leave behind an additional file (here is an example script to do that that may be instructive for someone who wants to do this on their team).
The random word pattern used in many other ORMs makes sense, because migrations are not monotonically incrementing IDs. With Drizzle, two migrations created simultaneously share an ID and may reference the wrong snapshot, so they necessarily must be manually resolved.
Obviously I would invite other solutions for dealing with conflicts. Merge queues, timestamp-as-ID or a smart resolve tool may be a better solution.
When you generate a migration, three files are modified:
{ID}_{two or three random words}.sql
, which describes the transformations to synchronize the database with the current state of the schema.meta/{ID}_snapshot.json
When two developers in separate branches create migrations simultaneously, files (2) and (3) will correctly result in conflicts, but file (1) will not. This means simple patterns like
merge --theirs && regenerate
leave behind an additional file (here is an example script to do that that may be instructive for someone who wants to do this on their team).The random word pattern used in many other ORMs makes sense, because migrations are not monotonically incrementing IDs. With Drizzle, two migrations created simultaneously share an ID and may reference the wrong snapshot, so they necessarily must be manually resolved.
Obviously I would invite other solutions for dealing with conflicts. Merge queues, timestamp-as-ID or a smart resolve tool may be a better solution.