storcon: squash all migrations into one #12795
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Neon and Hadron deployments have the same database schema, but different migration histories. Some transactions have different identifiers too. If we don't do anything about it, then the storage controller would fail to apply the merged set of transactions.
Summary of Changes
We squash all migrations into a single one. If the schema already matches, then the new transaction gets applie without doing anything. For new regions, this migration will bootstrap the database schema.
This should be merged in both neon and hadron codebases.
Note that after deploying this change, the
__diesel_schema_migrations
table will still contain entries for the old pre-squash transactions. This is fine because diesel only considers the tranasactions embedded in the repo for application. Once we are certain that we are not going to roll back, we can clean up the__diesel_schema_migrations
tables in prod, but this is manual and error prone, so I'd skip it.Rolling back
Rolling back to a previous deployment which embeds the non-squashed transactions is safe. The old transactions are still present in
__diesel_schema_migrations
(i.e. considered applied), so no migrations will be run, so no migrations will be run.Note that this assumes that all transactions are applied and squashed into the new migration before deployment.
Touches LKB-2482