Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: add data source query policy migrate scripts (#13061)

boojack8a1fa641d6a2
diff --git a/backend/migrator/migration/prod/2.22/0003##data_source_query_env_policy.sql b/backend/migrator/migration/prod/2.22/0003##data_source_query_env_policy.sql
new file mode 100644
index 0000000000..bee317721b
--- /dev/null
+++ b/backend/migrator/migration/prod/2.22/0003##data_source_query_env_policy.sql
@@ -0,0 +1,20 @@
+INSERT INTO policy (creator_id, updater_id, type, payload, resource_type, resource_id, inherit_from_parent)
+SELECT
+ 101,
+ 101,
+ 'bb.policy.data-source-query',
+ '{"adminDataSourceRestriction": "FALLBACK"}',
+ 'ENVIRONMENT',
+ e.id,
+ false
+FROM
+ environment e
+WHERE
+ NOT EXISTS (
+ SELECT 1
+ FROM policy p
+ WHERE
+ p.resource_type = 'ENVIRONMENT'
+ AND p.resource_id = e.id
+ AND p.type = 'bb.policy.data-source-query'
+ );
diff --git a/backend/migrator/migrator_test.go b/backend/migrator/migrator_test.go
index 5a50689470..92325183a7 100644
--- a/backend/migrator/migrator_test.go
+++ b/backend/migrator/migrator_test.go
@@ -230,5 +230,5 @@ func TestMigrationCompatibility(t *testing.T) {
func TestGetCutoffVersion(t *testing.T) {
releaseVersion, err := getProdCutoffVersion()
require.NoError(t, err)
- require.Equal(t, semver.MustParse("2.22.2"), releaseVersion)
+ require.Equal(t, semver.MustParse("2.22.3"), releaseVersion)
}