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: move idp schema change to prod (#4460)
boojack96f6781a9e1c
diff --git a/backend/store/migration/dev/LATEST.sql b/backend/store/migration/dev/LATEST.sqlindex b346feda89..a9a0b4a166 100644--- a/backend/store/migration/dev/LATEST.sql+++ b/backend/store/migration/dev/LATEST.sql@@ -10,6 +10,30 @@ BEGINEND;$$ LANGUAGE plpgsql;+-- idp stores generic identity provider.+CREATE TABLE idp (+ id SERIAL PRIMARY KEY,+ row_status row_status NOT NULL DEFAULT 'NORMAL',+ created_ts BIGINT NOT NULL DEFAULT extract(epoch from now()),+ updated_ts BIGINT NOT NULL DEFAULT extract(epoch from now()),+ resource_id TEXT NOT NULL,+ name TEXT NOT NULL,+ domain TEXT NOT NULL,+ type TEXT NOT NULL CONSTRAINT idp_type_check CHECK (type IN ('OAUTH2', 'OIDC')),+ -- config stores the corresponding configuration of the IdP, which may vary depending on the type of the IdP.+ config JSONB NOT NULL DEFAULT '{}'+);++CREATE UNIQUE INDEX idx_idp_unique_resource_id ON idp(resource_id);++ALTER SEQUENCE idp_id_seq RESTART WITH 101;++CREATE TRIGGER update_idp_updated_ts+BEFORE+UPDATE+ ON idp FOR EACH ROW+EXECUTE FUNCTION trigger_update_updated_ts();+-- principalCREATE TABLE principal (id SERIAL PRIMARY KEY,@@ -1182,29 +1206,3 @@ BEFOREUPDATEON external_approval FOR EACH ROWEXECUTE FUNCTION trigger_update_updated_ts();---- idp stores generic identity provider.-CREATE TABLE idp (- id SERIAL PRIMARY KEY,- row_status row_status NOT NULL DEFAULT 'NORMAL',- creator_id INTEGER NOT NULL REFERENCES principal (id),- created_ts BIGINT NOT NULL DEFAULT extract(epoch from now()),- updater_id INTEGER NOT NULL REFERENCES principal (id),- updated_ts BIGINT NOT NULL DEFAULT extract(epoch from now()),- resource_id TEXT NOT NULL,- name TEXT NOT NULL,- domain TEXT NOT NULL,- type TEXT NOT NULL CONSTRAINT idp_type_check CHECK (type IN ('OAUTH2', 'OIDC')),- -- config stores the corresponding configuration of the IdP, which may vary depending on the type of the IdP.- config JSONB NOT NULL DEFAULT '{}'-);--CREATE UNIQUE INDEX idx_idp_unique_resource_id ON idp(resource_id);--ALTER SEQUENCE idp_id_seq RESTART WITH 101;--CREATE TRIGGER update_idp_updated_ts-BEFORE-UPDATE- ON idp FOR EACH ROW-EXECUTE FUNCTION trigger_update_updated_ts();diff --git a/backend/store/migration/prod/1.12/0004##drop_pipeline_status.sql b/backend/store/migration/prod/1.12/0004##drop_pipeline_status.sqlindex d40366e729..ef86e21d9c 100644--- a/backend/store/migration/prod/1.12/0004##drop_pipeline_status.sql+++ b/backend/store/migration/prod/1.12/0004##drop_pipeline_status.sql@@ -1,3 +1,3 @@ALTER TABLE pipeline DROP COLUMN status;-DROP INDEX idx_pipeline_status;\ No newline at end of file+DROP INDEX IF EXISTS idx_pipeline_status;\ No newline at end of filediff --git a/backend/store/migration/dev/20230117000000##idp.sql b/backend/store/migration/prod/1.12/0005##idp.sqlsimilarity index 83%rename from backend/store/migration/dev/20230117000000##idp.sqlrename to backend/store/migration/prod/1.12/0005##idp.sqlindex 169564ee65..717113d3f4 100644--- a/backend/store/migration/dev/20230117000000##idp.sql+++ b/backend/store/migration/prod/1.12/0005##idp.sql@@ -2,9 +2,7 @@CREATE TABLE idp (id SERIAL PRIMARY KEY,row_status row_status NOT NULL DEFAULT 'NORMAL',- creator_id INTEGER NOT NULL REFERENCES principal (id),created_ts BIGINT NOT NULL DEFAULT extract(epoch from now()),- updater_id INTEGER NOT NULL REFERENCES principal (id),updated_ts BIGINT NOT NULL DEFAULT extract(epoch from now()),resource_id TEXT NOT NULL,name TEXT NOT NULL,@@ -24,6 +22,6 @@ UPDATEON idp FOR EACH ROWEXECUTE FUNCTION trigger_update_updated_ts();-ALTER TABLE principal DROP CONSTRAINT IF EXISTS idx_principal_unique_email;+DROP INDEX IF EXISTS idx_principal_unique_email;ALTER TABLE principal ADD COLUMN idp_id INTEGER REFERENCES idp (id);ALTER TABLE principal ADD COLUMN idp_user_info JSONB NOT NULL DEFAULT '{}';diff --git a/backend/store/migration/prod/LATEST.sql b/backend/store/migration/prod/LATEST.sqlindex 1118147c5c..63cf985c1e 100644--- a/backend/store/migration/prod/LATEST.sql+++ b/backend/store/migration/prod/LATEST.sql@@ -10,6 +10,30 @@ BEGINEND;$$ LANGUAGE plpgsql;+-- idp stores generic identity provider.+CREATE TABLE idp (+ id SERIAL PRIMARY KEY,+ row_status row_status NOT NULL DEFAULT 'NORMAL',+ created_ts BIGINT NOT NULL DEFAULT extract(epoch from now()),+ updated_ts BIGINT NOT NULL DEFAULT extract(epoch from now()),+ resource_id TEXT NOT NULL,+ name TEXT NOT NULL,+ domain TEXT NOT NULL,+ type TEXT NOT NULL CONSTRAINT idp_type_check CHECK (type IN ('OAUTH2', 'OIDC')),+ -- config stores the corresponding configuration of the IdP, which may vary depending on the type of the IdP.+ config JSONB NOT NULL DEFAULT '{}'+);++CREATE UNIQUE INDEX idx_idp_unique_resource_id ON idp(resource_id);++ALTER SEQUENCE idp_id_seq RESTART WITH 101;++CREATE TRIGGER update_idp_updated_ts+BEFORE+UPDATE+ ON idp FOR EACH ROW+EXECUTE FUNCTION trigger_update_updated_ts();+-- principalCREATE TABLE principal (id SERIAL PRIMARY KEY,@@ -21,11 +45,11 @@ CREATE TABLE principal (type TEXT NOT NULL CHECK (type IN ('END_USER', 'SYSTEM_BOT', 'SERVICE_ACCOUNT')),name TEXT NOT NULL,email TEXT NOT NULL,- password_hash TEXT NOT NULL+ password_hash TEXT NOT NULL,+ idp_id INTEGER REFERENCES idp (id),+ idp_user_info JSONB NOT NULL DEFAULT '{}');-CREATE UNIQUE INDEX idx_principal_unique_email ON principal(email);-CREATE TRIGGER update_principal_updated_tsBEFOREUPDATEdiff --git a/backend/store/pg_engine_test.go b/backend/store/pg_engine_test.goindex da871571a6..49cc6c5fbd 100644--- a/backend/store/pg_engine_test.go+++ b/backend/store/pg_engine_test.go@@ -220,5 +220,5 @@ func TestMigrationCompatibility(t *testing.T) {func TestGetCutoffVersion(t *testing.T) {releaseVersion, err := getProdCutoffVersion()require.NoError(t, err)- require.Equal(t, semver.MustParse("1.12.4"), releaseVersion)+ require.Equal(t, semver.MustParse("1.12.5"), releaseVersion)}