Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: migrate targets (#16293)
Danny Xu1be753487d04
diff --git a/backend/migrator/migration/3.7/0011##migrate_plan_target_to_targets.sql b/backend/migrator/migration/3.7/0011##migrate_plan_target_to_targets.sqlnew file mode 100644index 0000000000..2eeb32fe31--- /dev/null+++ b/backend/migrator/migration/3.7/0011##migrate_plan_target_to_targets.sql@@ -0,0 +1,32 @@+-- Migrate plan config from single "target" to array "targets" for changeDatabaseConfig only+UPDATE plan+SET config = jsonb_set(+ config,+ '{specs}',+ (+ SELECT jsonb_agg(+ CASE+ -- Handle changeDatabaseConfig with target field+ WHEN spec_value->'changeDatabaseConfig' ? 'target' THEN+ jsonb_set(+ spec_value,+ '{changeDatabaseConfig}',+ jsonb_set(+ (spec_value->'changeDatabaseConfig')::jsonb - 'target',+ '{targets}',+ jsonb_build_array(spec_value->'changeDatabaseConfig'->'target')+ )+ )+ -- Keep other specs unchanged+ ELSE spec_value+ END+ )+ FROM jsonb_array_elements(config->'specs') AS spec_value+ )+)+WHERE config ? 'specs'+ AND EXISTS (+ SELECT 1+ FROM jsonb_array_elements(config->'specs') AS spec+ WHERE spec->'changeDatabaseConfig' ? 'target'+ );\ No newline at end of filediff --git a/backend/migrator/migrator_test.go b/backend/migrator/migrator_test.goindex bdc9e45778..4cf0bcfa41 100644--- a/backend/migrator/migrator_test.go+++ b/backend/migrator/migrator_test.go@@ -12,7 +12,7 @@ import (func TestLatestVersion(t *testing.T) {files, err := getSortedVersionedFiles()require.NoError(t, err)- require.Equal(t, semver.MustParse("3.7.10"), *files[len(files)-1].version)+ require.Equal(t, semver.MustParse("3.7.11"), *files[len(files)-1].version)}func TestVersionUnique(t *testing.T) {