-
Notifications
You must be signed in to change notification settings - Fork 19
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
Support for views #88
Conversation
pg-osc will now re-create any views after the table name swap. Because pg-osc uses shadow tables, after the name swap happens, views can continue to refer the old table name. This isn't ideal. Instead, we now perform a CREATE OR REPLACE VIEW... after the swap is perform. We do it after swap to ensure any view creation doesn't keep the exclusive lock held for a longer duration
lib/pg_online_schema_change/query.rb
Outdated
@@ -301,6 +301,21 @@ def storage_parameters_for(client, table, reuse_trasaction = false) | |||
columns.first | |||
end | |||
|
|||
def view_definitions_for(client, table) | |||
query = <<~SQL | |||
select * |
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.
I think we can probably do better than this query. We should be able to use pg_depend
like this postgres wiki article details.
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.
ah nice! good call. Updated!
Good for review now. Will release it today/tomorrow. |
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.
LGTM!
pg-osc will now re-create any views after the table name swap. Because pg-osc uses shadow tables, after the name swap happens, views can continue to refer the old table name. This isn't ideal.
Instead, we now perform a
CREATE OR REPLACE VIEW
... after the swap is performed. We do it after swap to ensure any view creation doesn't keep the exclusive lock held for a longer duration.Closes: #81