Replies: 1 comment 1 reply
-
Hey, @plutino 👋 Atlas Sum was created excatly for this use case. Since both Atlas and its users cannot rely on the fact that out-of-order schema changes are independent, having this file (+ enabling migration linting/validation in CI) enforces a true linear migration history when changes are merged into the master branch. Applying migration files in their correct order maintains predictable and replayable migration history that can be executed anywhere, regardless of the actual version the target database is currently on (e.g., a common use case when you ship software and do not control its deployment). If migration linting is enabled in CI, a user cannot merge their changes into the master branch if a new migration file was added that they are not aware of (because Attached are two nice screenshots on this subject from a presentation I did some time ago: |
Beta Was this translation helpful? Give feedback.
-
Hi there.
We are evaluating a DB schema management workflow based one Atlas versioned migrations. One particular scenario we try to resolve is when two migrations are merged out-of-order. For example, two teams work on two different migrations, version 3 and version 4. The PR with version 4 is merged first, and applied to all database in different environments. The PR with version 3 is then merged.
Since Atlas keep full migration history in the versions table, we have expected that it can pick up that a migration is missing and apply it. This could lead to inconsistencies between databases, but it seems fine since, in practice, out-or-order schema changes are usually independent.
This, however, seems not to be the case with Atlas.
atlas migrate status
andatlas migrate apply
don't seem detect the missing migration before the current version, or we have missed something.What's the recommended practice for this scenario? We don't want to change migration version during merge because we also want to support the use case that a migration can be applied to some environment before it's merged to master. A version change in this case would require changes on the specific environment to be rolled back, which seems harder to managed than allowing migrations to be applied out-of-order.
Thanks and any comments and suggestions are appreciated.
Beta Was this translation helpful? Give feedback.
All reactions