Squash and fix migrations so they run against an empty schema #24
Labels
No Label
bug
duplicate
enhancement
help wanted
invalid
new
question
wontfix
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: DMC/scipro#24
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "empty-database-migration"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This is one requirement in bringing #15 to reality.
Currently there are some 450 migration scripts that have been added over the past 11 years. Unfortunately some of these migration scripts have some defects. Either from the fact that they are very old and from another database engine (MySQL vs currently MariaDB), make assumptions about the database name, or its contents. Due to these defects trying to bring an empty schema up-to-date by running all migrations will fail with 372 being the main blocker.
If it is not possible to bring an empty schema up-to-date it is a major hindrance to the plan of automatically deploying test servers for every pull request (#15). These changes makes it possible to bring an empty schema up to the latest version by squashing all migration scripts to a single new baseline with the necessary fixes to work on an empty schema.
There is a downside with the way it accomplishes this, it requires any non-empty schema to already be at version 392.2. Flyway, the product we use for database migrations, does not support new baseline scripts in the free version, only in the paid edition. To get around this, Flyway is tricked into thinking the database has never used Flyway before by changing which database table stores the information about applied migrations. This is the reason the database has to be at the latest (392.2) version before deploying the new version of SciPro that include this change, because Flyway will have no way to see which of the old migrations have been applied.
An alternative would be to fix the old migrations so they would work on an empty schema. However, since every migration script is checksummed to see that the applied version is the correct one every database would have to be "repaired" to update its checksums. This choice was not taken for two reasons:
How to test with an existing schema
develop
branch as of 2024-11-22)How to test with an empty schema
admin@example.com
that is created by theDataInitializer