-
Notifications
You must be signed in to change notification settings - Fork 70
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
Add SQL onComplete
flag, allow sql
migration to run with others
#280
Conversation
by default, SQL migrations run on start. This change allows for special SQL migrations that run only on the complete step.
This reverts commit 24f6822.
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 looks good. I left a lot of small comments.
// we don't want to refresh the schema if the operation is not isolated as it would | ||
// override changes made by other operations | ||
if refreshOp, ok := op.(migrations.RequiresSchemaRefreshOperation); ok && refreshOp.RequiresSchemaRefresh() { | ||
if isolatedOp, ok := op.(migrations.IsolatedOperation); ok && isolatedOp.IsIsolated() { |
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.
Why do we now only refresh schema for ops that are both RequiresSchemaRefreshOperation
and IsolatedOperation
rather than just RequiresSchemaRefreshOperation
?
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.
Main reason is: that it could be non-isolated & require schema refresh. That's the case for migrations with onComplete
.
Migrations that are not isolated & require a schema refresh on Start
phase would surely break others, as it would override the resulting schema from the start ops, by refreshing it afterwards. I tried to capture this in the comment
Co-authored-by: Andrew Farries <[email protected]>
Co-authored-by: Andrew Farries <[email protected]>
Co-authored-by: Andrew Farries <[email protected]>
Co-authored-by: Andrew Farries <[email protected]>
This change updates the
sql
operation to:onComplete
flag, that will make it run on the Complete phase, rather than doing it during Start (default behavior).sql
operations next to others in the same migration. We added this limitation to ensure this operation doesn't affect others, especially around schema state management.Having
sql
next to other operations has proven convenient sometimes, by addingonComplete
flag, we can allow for these migrations to run and rely on views recreation based on the final state.