Skip to content
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 an AlterViewModel and AlterMaterializedViewModel as available operations #161

Open
zschumacher opened this issue Nov 12, 2021 · 2 comments

Comments

@zschumacher
Copy link

It would be amazing that when I change a query on a PostgresViewModel or PostgresMaterializedViewModel, if psqlextra would generate an alter view migration for me. Currently, I have to either do a SeperateDatabaseAndState to alter the view, or manually add a delete and create view operation to a migration.

@zschumacher
Copy link
Author

zschumacher commented Nov 12, 2021

Realizing that Postgres doesn't have an alter view mechanism for modifying the query, but auto dropping and creating the view would be nice!

@Photonios
Copy link
Member

This is supported already by the schema editor:

For views:

def replace_view_model(self, model: Model) -> None:

For materialized views:
def replace_materialized_view_model(self, model: Model) -> None:

I didn't wrap them in migration operations yet because I haven't figured out how to cleanly detect the query changing. You're free to open a PR to at least at the operations for manual use :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants