-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Restoring the microcluster migration history #689
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Questions regarding the migration order
SchemaExtensions = []schema.Update{ | ||
schemaApplyMigration("kubernetes-auth-tokens", "000-create.sql"), | ||
schemaApplyMigration("cluster-configs", "000-create.sql"), | ||
schemaApplyMigration("worker-nodes", "000-create.sql"), | ||
schemaApplyMigration("worker-tokens", "000-create.sql"), | ||
schemaApplyMigration("feature-status", "000-feature-status.sql"), | ||
schemaApplyMigration("worker-tokens", "001-add-expiry.sql"), | ||
schemaApplyMigration("worker-nodes", "002-delete.sql"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it sounds like the order and names of these migrations is important -- but we've just got bare strings identifying them. Also, are they lexicographically ordered or numerically ordered? I'm worried about the day we run out of numbers (999).
⚡ ls -al
total 8
drwxrwxr-x 2 addyess addyess 4096 Sep 20 13:14 .
drwxrwxr-x 12 addyess addyess 4096 Sep 20 13:13 ..
-rw-rw-r-- 1 addyess addyess 0 Sep 20 13:13 0001-stuff
-rw-rw-r-- 1 addyess addyess 0 Sep 20 13:13 001-stuff
-rw-rw-r-- 1 addyess addyess 0 Sep 20 13:14 0090-stuff
-rw-rw-r-- 1 addyess addyess 0 Sep 20 13:14 009-stuff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the alternative i'm hoping for:
⚡ ls -alv
total 8
drwxrwxr-x 2 addyess addyess 4096 Sep 20 13:14 .
drwxrwxr-x 12 addyess addyess 4096 Sep 20 13:13 ..
-rw-rw-r-- 1 addyess addyess 0 Sep 20 13:13 0001-stuff
-rw-rw-r-- 1 addyess addyess 0 Sep 20 13:13 001-stuff
-rw-rw-r-- 1 addyess addyess 0 Sep 20 13:14 009-stuff
-rw-rw-r-- 1 addyess addyess 0 Sep 20 13:14 0090-stuff
Restoring the Microcluster Migration History
This PR restores our microcluster schema migration history to the original order.
Issue
We had an issue where the latest migration did not get applied: #634
Cause
The reason for this issue is that a migration was removed without dropping the schema version count. Consequently, when refreshing the snap the microcluster migration thought more migrations were already applied, leaving the latest migration un-applied.
Fix
This PR restores the schema migration order which will need to be back-ported into all 1.31 branches.
It is not good practice to remove a migration, this does not remove the existing table. A second migration should be in place to remove the table maintaining the accurate migration history.
Note on Prefix count
We should have labeled these 001-007 in the first place. It is not good practice to change the existing migration name (in case microcluster introduces checks around migration names). To support the idea of sequential migrations I choose to name the latest migration 002.