Skip to content

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

Add trigger to update update_ts on UPDATE

天舟7a012c390045
diff --git a/backend/sqlite/migration/0001_init_schema.up.sql b/backend/sqlite/migration/0001_init_schema.up.sql
index cb55244e37..4e1a2e2936 100644
--- a/backend/sqlite/migration/0001_init_schema.up.sql
+++ b/backend/sqlite/migration/0001_init_schema.up.sql
@@ -13,6 +13,19 @@ CREATE TABLE principal (
password_hash TEXT NOT NULL
);
+CREATE TRIGGER IF NOT EXISTS `trigger_update_principal_modification_time`
+AFTER
+UPDATE
+ ON `principal` FOR EACH ROW BEGIN
+UPDATE
+ `principal`
+SET
+ updated_ts = (strftime('%s', 'now'))
+WHERE
+ rowid = old.rowid;
+
+END;
+
-- Default bytebase system account id is 1
INSERT INTO
principal (
@@ -54,6 +67,19 @@ CREATE TABLE workspace (
name TEXT NOT NULL
);
+CREATE TRIGGER IF NOT EXISTS `trigger_update_workspace_modification_time`
+AFTER
+UPDATE
+ ON `workspace` FOR EACH ROW BEGIN
+UPDATE
+ `workspace`
+SET
+ updated_ts = (strftime('%s', 'now'))
+WHERE
+ rowid = old.rowid;
+
+END;
+
-- Default workspace for on-premise deployment, id is 1
INSERT INTO
workspace (