3 ms·
Something like this simpleminded approach: Use VCS tags to identify schema versions, and a naming convention including those tags to track the migration files.
by mjw1007 7y ago
Something like this simpleminded approach:
Use VCS tags to identify schema versions, and a naming convention including those tags to track the migration files.
Have a script that validates a migration in the obvious sort of way (check out the project that contains the schema at tag a; add some data; apply the migration; dump the schema; compare that against a dump made directly from tag b).
Maintain a store of migrations that have been validated in that way; the way to add a migration to that store goes through the checking script.
Store the tag corresponding to each database's current schema in the database itself (and have something automated to check it regularly if you like; that's basically the same code as the migration-checking script).
Make the only way to change an important database's schema be to run a script that takes the migration from that store, reading the starting tag from the database.