Skip to content

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

Make db.source_backup_id reference backup(id)

天舟aa0500079548
diff --git a/store/migration/10001__init_schema.sql b/store/migration/10001__init_schema.sql
index 4bbe305354..32e00ae17e 100644
--- a/store/migration/10001__init_schema.sql
+++ b/store/migration/10001__init_schema.sql
@@ -378,7 +378,8 @@ CREATE TABLE db (
updated_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')),
instance_id INTEGER NOT NULL REFERENCES instance (id),
project_id INTEGER NOT NULL REFERENCES project (id),
- source_backup_id INTEGER,
+ -- If db is restored from a backup, then we will record that backup id. We can thus trace up to the original db.
+ source_backup_id INTEGER REFERENCES backup (id) ON DELETE SET NULL,
sync_status TEXT NOT NULL CHECK (sync_status IN ('OK', 'NOT_FOUND')),
last_successful_sync_ts BIGINT NOT NULL,
name TEXT NOT NULL,