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

Restore permissions when dropping and recreating a matview #213

Open
corviday opened this issue Mar 26, 2024 · 2 comments
Open

Restore permissions when dropping and recreating a matview #213

corviday opened this issue Mar 26, 2024 · 2 comments

Comments

@corviday
Copy link
Contributor

When a materialized view is changed by a migration, the view is DROPped and then CREATEd. The newly created version does not inherit the permissions the DROPped view had.

Recently we had this issue with the upgrade of vars_per_history_mv . It was fixed with the following command:

grant select on crmp.vars_per_history_mv to viewer;

This command should be incorporated into migration 3505750d3416 for both upgrades and downgrades.

@rod-glover
Copy link
Contributor

  1. Yes.
  2. There's a handy bit of tooling that incorporates much of the work, including indexes and privilege management, into single calls. Those calls are create_matview and drop_matview. For example usages, see https://github.com/pacificclimate/pycds/blob/master/pycds/alembic/versions/bb2a222a1d4a_convert_obs_count_per_month_history_mv_.py .

@rod-glover
Copy link
Contributor

There are several other migrations that use these utility methods as well, for additional examples.

Nospamas added a commit that referenced this issue Mar 26, 2024
…sions.

 - Updates migration 3505750d3416 to use the correct utility functions.
 - Add warning in utility functions when no schema name is present.
Nospamas added a commit that referenced this issue Mar 26, 2024
Nospamas added a commit that referenced this issue Mar 26, 2024
 #213 Use utility functions when recreating objects to correct permissions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants