-
-
Notifications
You must be signed in to change notification settings - Fork 241
Open
Description
Use case:
- I have bunch of materialized views, each w/ multiple past versions.
- I'm updating the column type of a bunch of underlying data from
:stringto:citextso I can more easily do case-insensitive sorting. - I'm unable to do those
change_coumn :table, :field, :citextmigrations because views depend on the columns I'm changing.
Current solution:
- Drop all the materialized views.
- Run my citext migrations.
- Delete all old sql files except the most recent one for each of the materialized views I need to resurrect.
- Delete any recent
update_viewmigrations that haven't run in production yet so that when I deploy to production, those migrations don't blow up because the SQL files are missing. - Rename the most recent SQL file to
_001for each view. - Create brand-new materialized views with the same names as the old ones with
create_view :view_name, materialized: true.(I had to do the deleting and renaming becausecreate_viewautomatically uses the_001definition. I couldn't useupdate_viewbecause I previously dropped the views.)
Proposed solutions:
- Add a
recreate_view :view_namemigration method that allows me to pick up where I left off and retain all my historical sql files.- It would behave like
create_view, but it would automatically increment and use the next sequential version suffix.
- It would behave like
- Open to other suggestions.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels