Add script to verify migration rollback
What does this MR do?
Related to #263309 (closed)
Add a new script that will validate migrations. The new script was originally intended to test migration rollback, which is a gap in the currently used scripts/schema_changed
. On testing this MR, we found that scripts/schema_changed
doesn't properly validate db/structure.sql
, so hopefully scripts/schema_changed
can be replaced altogether.
The new script only executes if migrations were added to the source branch of the MR, and does three things:
- Rollback the new migrations and validate that
db/structure.sql
is reverted to the previous known state on the target branch - Re-migrate the database and validate that
db/structure.sql
has a clean diff against the source branch (indicating the correctstructure.sql
was committed) - Validate that the correct
db/schema_migrations
version files were committed
This seems to work out so far, but for the time being we'll allow job failures until we've used it for a while.
Post-merge tasks
-
Post to #development
: https://gitlab.slack.com/archives/C02PF508L/p1609847300342900 -
Post to the Engineering Week in Review
Edited by Rémy Coutable