Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Introduce policy table for storing per environment policies.
spinningbotfd6f9f9ac0ec
diff --git a/store/migration/10001__init_schema.sql b/store/migration/10001__init_schema.sqlindex 4f0b62432e..daa2b506ae 100644--- a/store/migration/10001__init_schema.sql+++ b/store/migration/10001__init_schema.sql@@ -165,6 +165,42 @@ WHEREEND;+-- Policy+-- policy stores the policies for each environment.+CREATE TABLE policy (+ id INTEGER PRIMARY KEY AUTOINCREMENT,+ row_status TEXT NOT NULL CHECK (+ row_status IN ('NORMAL', 'ARCHIVED')+ ) DEFAULT 'NORMAL',+ creator_id INTEGER NOT NULL REFERENCES principal (id),+ created_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')),+ updater_id INTEGER NOT NULL REFERENCES principal (id),+ updated_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')),+ environment_id INTEGER NOT NULL REFERENCES environment (id),+ type TEXT NOT NULL,+ payload TEXT NOT NULL+);++CREATE INDEX idx_policy_environment_id ON policy(environment_id);++INSERT INTO+ sqlite_sequence (name, seq)+VALUES+ ('policy', 100);++CREATE TRIGGER IF NOT EXISTS `trigger_update_policy_modification_time`+AFTER+UPDATE+ ON `policy` FOR EACH ROW BEGIN+UPDATE+ `policy`+SET+ updated_ts = (strftime('%s', 'now'))+WHERE+ rowid = old.rowid;++END;+-- ProjectCREATE TABLE project (id INTEGER PRIMARY KEY AUTOINCREMENT,diff --git a/store/seed/test/10000__reset.sql b/store/seed/test/10000__reset.sqlindex b15f78859c..03dca577d8 100644--- a/store/seed/test/10000__reset.sql+++ b/store/seed/test/10000__reset.sql@@ -71,6 +71,9 @@ DELETE FROMDELETE FROMenvironment;+DELETE FROM+ policy;+DELETE FROMproject_webhook;diff --git a/store/seed/test/10050__environment.sql b/store/seed/test/10050__environment.sqlindex 11fcfd1b15..9b158e2c1d 100644--- a/store/seed/test/10050__environment.sql+++ b/store/seed/test/10050__environment.sql@@ -93,4 +93,23 @@ VALUES'Archived Env 1',4,'MANUAL_APPROVAL_NEVER'- );\ No newline at end of file+ );++INSERT INTO+ policy (+ id,+ creator_id,+ updater_id,+ environment_id,+ type,+ payload+ )+VALUES+ (+ 1001,+ 101,+ 101,+ 5004,+ 'approval_policy',+ 'MANUAL_APPROVAL_ALWAYS'+ );