Squarespace / pgbedrock

Manage a Postgres cluster's roles, role memberships, schema ownership, and privileges
https://pgbedrock.readthedocs.io/en/latest/
Other
311 stars 35 forks source link

Add table and sequence ownership to pgbedrock #26

Closed zcmarine closed 6 years ago

zcmarine commented 6 years ago

This PR addresses Issue #4 (Support table and sequence ownership).

It does so by doing 3 things:

  1. Have pgbedrock generate add table and sequence ownership information into the spec that pgbedrock generates.
  2. Have the spec_inspector module validate a variety of conditions that are necessary in order for us to manage ownerships: that a spec has no objects with multiple owners, has no objects with no owners, has no auto-dependent objects listed with owners, and has no objects in the spec that are not in the database. This allows pgbedrock configure to run without having to check a ton of edge cases while it executes.
  3. Have pgbedrock configure manage table and sequence ownership.

I have added tests to validate that the above 3 items work as expected and have also verified that doing pgbedrock generate followed by pgbedrock configure both runs on our staging database and that it shows no changes.

I know that this PR is kind of large and painful: these 3 things all depend upon each other, so they need to all be merged into master concurrently. Ideally this might have been a feature branch with 3 separate PRs added to it. That didn't happen though, so if there's any way I can make this less painful to read through let me know.