Skip to content

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

Tenancy: add deployment config to schema. (#90)

spinningbot3d812586b290
diff --git a/store/migration/10001__init_schema.sql b/store/migration/10001__init_schema.sql
index 2336772bac..db0c19376e 100644
--- a/store/migration/10001__init_schema.sql
+++ b/store/migration/10001__init_schema.sql
@@ -1300,3 +1300,39 @@ WHERE
rowid = old.rowid;
END;
+
+-- Deployment Configuration.
+-- deployment_config stores deployment configurations at project level.
+CREATE TABLE deployment_config (
+ 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')),
+ project_id INTEGER NOT NULL REFERENCES project (id),
+ name TEXT NOT NULL,
+ config TEXT NOT NULL
+);
+
+CREATE UNIQUE INDEX idx_deployment_config_project_id ON deployment_config(project_id);
+
+INSERT INTO
+ sqlite_sequence (name, seq)
+VALUES
+ ('deployment_config', 100);
+
+CREATE TRIGGER IF NOT EXISTS `trigger_update_deployment_config_modification_time`
+AFTER
+UPDATE
+ ON `deployment_config` FOR EACH ROW BEGIN
+UPDATE
+ `deployment_config`
+SET
+ updated_ts = (strftime('%s', 'now'))
+WHERE
+ rowid = old.rowid;
+
+END;
\ No newline at end of file
diff --git a/store/seed/test/10000__reset.sql b/store/seed/test/10000__reset.sql
index c55259179b..1613582da9 100644
--- a/store/seed/test/10000__reset.sql
+++ b/store/seed/test/10000__reset.sql
@@ -89,6 +89,9 @@ DELETE FROM
DELETE FROM
label_key;
+DELETE FROM
+ deployment_config;
+
-- Project 1 refers to DEFAULT project which is considered as part of schema
DELETE FROM
project
diff --git a/store/seed/test/10210__deployment_config.sql b/store/seed/test/10210__deployment_config.sql
new file mode 100644
index 0000000000..b20df26f93
--- /dev/null
+++ b/store/seed/test/10210__deployment_config.sql
@@ -0,0 +1,19 @@
+-- Deployment config with regional deployments for project 3005.
+INSERT INTO
+ deployment_config (
+ id,
+ creator_id,
+ updater_id,
+ project_id,
+ name,
+ config
+ )
+VALUES
+ (
+ 21001,
+ 101,
+ 101,
+ 3005,
+ 'regional',
+ '{"deployment_config":{"deployments":[{"spec":{"selector":{"matchExpressions":[{"key":"location","operator":"IN","values":["us-central1","europe-west1"]}]}}},{"spec":{"selector":{"matchExpressions":[{"key":"location","operator":"EXISTS"}]}}}]}}'
+ );