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

trs/wip/schema-ownership #242

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

trs/wip/schema-ownership #242

wants to merge 2 commits into from

Conversation

tsibley
Copy link
Member

@tsibley tsibley commented Jul 23, 2021

Some notes in commits. Very old branch. Attempts to systematically address ownership of schema objects so they're not owned by the postgres "superuser", but by a dedicated id3c role. Not complete, maybe not worth completing. Paired PR in id3c-customizations.

Create id3c role manually
  as superuser

Re-assign all existing owners

Add "set local role id3c" to templates
Add "set local role id3c" retroactively to existing changes

Create an id3c database role to be the owner of all database objects

To reassign all existing database objects in our seattleflu.org
production instance, I've written a SQL script, reassign-owners.sql, in
our id3c-customizations repo.  It should be run once after deploying
this change.

To maintain the id3c owner going forward, this adds a "set role id3c"
statement to the top of our Sqitch templates.

To maintain the id3c owner for development/testing deploys into empty
databases, existing Sqitch changes are retroactively adjusted to include
"set role id3c".  This necessitates putting the roles/id3c/create change
near the start of the Sqitch plan.
TODO:

- Cleanup commits
- Test initial deploy into empty database

PGHOST=localhost PGPORT=65432 PGUSER=postgres PGPASSWORD=badpass createuser --no-login --createrole id3c
PGHOST=localhost PGPORT=65432 PGUSER=postgres PGPASSWORD=badpass createdb --encoding=UTF-8 --owner=id3c seattleflu
PGHOST=localhost PGPORT=65432 PGUSER=postgres PGPASSWORD=badpass psql -c "alter schema public owner to id3c" seattleflu
PGUSER=postgres PGPASSWORD=badpass sqitch deploy db:pg://localhost:65432/seattleflu
@tsibley tsibley changed the title trs/wip/schema ownership trs/wip/schema-ownership Jul 23, 2021
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

Successfully merging this pull request may close these issues.

1 participant