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

[SNOW-198] Create ownership database roles for data warehouse #104

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

philerooski
Copy link
Collaborator

synapse_data_warehouse/database_roles/V2.31.0__database_access_roles.sql

  • Since these are database-level objects, as opposed to account-level, we create these database roles and make grants on them within a versioned script.
  • This is the first time we are creating a database-level object which is not a schema. Normally, a versioned script would exist within its associated schema folder, like synapse_data_warehouse/synapse/.... But since database roles are database-level objects, I write them to their own folder under synapse_data_warehouse/database_roles. I would like to move synapse_data_warehouse/synapse and synapse_data_warehouse/synapse_raw to synapse_data_warehouse/schemas/... for uniformity, but I'll need to check if this works well with the synapse_data_warehouse/schemachange-config.yml file. Let me know if you prefer the database_roles folder alongside of the schema folders like it currently is in the PR.

admin/grants.sql

  • Although SYSADMIN has OWNERSHIP privileges on most or all of the objects having their ownership transferred here, we need MANAGE GRANTS privileges to COPY CURRENT GRANTS along with ownership.
  • Granting ownership can be finicky, and running these grant commands every time we deploy to production might cause some issues. I'll do some additional testing to make sure these grants are idempotent.

@philerooski philerooski requested a review from a team as a code owner January 16, 2025 01:04
-- Create database roles which will own the respective namespace's objects
CREATE OR REPLACE DATABASE ROLE SYNAPSE_ALL_ADMIN;
CREATE OR REPLACE DATABASE ROLE SYNAPSE_RAW_ALL_ADMIN;
CREATE OR REPLACE DATABASE ROLE SCHEMACHANGE_ALL_ADMIN;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I use CREATE OR REPLACE instead of CREATE IF NOT EXISTS because if we were to rollback/replay these changes, we would want our database roles to be privilege-free.

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