-
Notifications
You must be signed in to change notification settings - Fork 56
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
Use a transaction to run data migrations #3157
Conversation
@@ -79,6 +80,10 @@ func TestMigrations(t *testing.T) { | |||
err := m.Migrate() | |||
assert.NilError(t, err) | |||
|
|||
t.Run("run again to check idempotency", func(t *testing.T) { |
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.
good idea 👍
db262a2
to
7e77d1d
Compare
To check for idempotency. Also add HasFunction for checking if a function exists.
So that any failures are rolled back. We use a single transaction for all migrations because on-prem deploys will likely want to keep the old schema if any of the migrations in a new version fail.
7e77d1d
to
a2da753
Compare
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.
Ok, the other PRs have merged, so the TODO has been resolved.
This should be ready for a review
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.
looks good to me
Summary
Also run each migration twice in the migration test to check for idempotence. Includes a couple fixes to migrations to make them idempotent.