Description
Let says, "Francis" adds a migration M1 on branch X and still working on other stuff before proposing a PR.
A couple minutes the migration M1 was created, "Felipe" is working on the branch Y. Then, he creates the migration M2. Branch Y is way simpler than branch X. Hence, Felipe gets it done ASAP and post the PR and it gets merged.
After that, the CI does its job and releases the new version, running M2. Nice!!
In the next day, Francis finishes the work in the branch X and creates his PR. Now the CI does the same process and releases the changes in a new version. However, M1 never gets executed because M1 has its date time before M2 which was already executed.
Late migration: To be clear, by late migration I mean a migration added before the current version in the database.
Current system
The current system keeps track of what was executed by having a simple "current version" (time.Time). So if a late migration is added, it will simply ignore it and no complains will be reported in the migration tool, leading the CI to proceed and release a misdeployed version.
Proposal
Keep track of the executed migrations and if a late migration is detected, implement the migration engine to fail.
Description
Let says, "Francis" adds a migration
M1on branchXand still working on other stuff before proposing a PR.A couple minutes the migration M1 was created, "Felipe" is working on the branch
Y. Then, he creates the migration M2. BranchYis way simpler than branchX. Hence, Felipe gets it done ASAP and post the PR and it gets merged.After that, the CI does its job and releases the new version, running M2. Nice!!
In the next day, Francis finishes the work in the branch
Xand creates his PR. Now the CI does the same process and releases the changes in a new version. However, M1 never gets executed because M1 has its date time before M2 which was already executed.Late migration: To be clear, by late migration I mean a migration added before the current version in the database.
Current system
The current system keeps track of what was executed by having a simple "current version" (
time.Time). So if a late migration is added, it will simply ignore it and no complains will be reported in the migration tool, leading the CI to proceed and release a misdeployed version.Proposal
Keep track of the executed migrations and if a late migration is detected, implement the migration engine to fail.