Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix: migrate project owner IAM bindings (#20158)
p0nyad9ec082a84e
diff --git a/backend/migrator/migration/3.15/0009##migrate_iam_binding_environment_condition.sql b/backend/migrator/migration/3.15/0009##migrate_iam_binding_environment_condition.sqlindex 17bb25b2de..ea2bd631bd 100644--- a/backend/migrator/migration/3.15/0009##migrate_iam_binding_environment_condition.sql+++ b/backend/migrator/migration/3.15/0009##migrate_iam_binding_environment_condition.sql@@ -3,7 +3,7 @@-- Otherwise:-- 1. Replace sqlEditorUser with sqlEditorReadUser (keep existing conditions intact)-- 2. Add a new sqlEditorUser binding scoped to allowed environments--- 3. Scope custom roles with bb.sql.ddl/bb.sql.dml to allowed environments+-- 3. Scope project owner and custom roles with bb.sql.ddl/bb.sql.dml to allowed environmentsWITH-- Get all environment IDs from the setting table@@ -37,8 +37,10 @@ env_list AS (SELECT COALESCE(string_agg('"' || env_id || '"', ', '), '') AS env_idsFROM allowed_envs),--- Custom roles with bb.sql.ddl or bb.sql.dml-custom_roles_with_env_limitation AS (+-- Roles with environment limitations: project owner and custom roles with bb.sql.ddl or bb.sql.dml+roles_with_env_limitation AS (+ SELECT 'roles/projectOwner' AS role_name+ UNIONSELECT 'roles/' || resource_id AS role_nameFROM roleWHERE permissions->'permissions' @> '["bb.sql.ddl"]'::jsonb@@ -53,7 +55,7 @@ SET payload = (SELECT COALESCE(jsonb_agg(new_binding ORDER BY ord), '[]'::jsonb)FROM (-- Existing bindings: swap sqlEditorUser -> sqlEditorReadUser,- -- and add env condition to custom roles with DDL/DML+ -- and add env condition to roles with environment limitationsSELECT rn AS ord,CASE-- sqlEditorUser: replace with sqlEditorReadUser@@ -61,8 +63,8 @@ SET payload = (AND COALESCE(binding->'condition'->>'expression', '') NOT LIKE '%resource.environment_id%'THEN jsonb_set(binding, '{role}', '"roles/sqlEditorReadUser"')- -- Custom roles: add env condition- WHEN binding->>'role' IN (SELECT role_name FROM custom_roles_with_env_limitation)+ -- Environment-limited roles: add env condition+ WHEN binding->>'role' IN (SELECT role_name FROM roles_with_env_limitation)AND COALESCE(binding->'condition'->>'expression', '') NOT LIKE '%resource.environment_id%'THENCASE