Skip to content

Add script to verify migration rollback

Patrick Bair requested to merge 263309-verify-db-rollback-in-ci into master

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:

  1. Rollback the new migrations and validate that db/structure.sql is reverted to the previous known state on the target branch
  2. Re-migrate the database and validate that db/structure.sql has a clean diff against the source branch (indicating the correct structure.sql was committed)
  3. 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

Edited by Rémy Coutable

Merge request reports