Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Allow database_id be NULL in anomaly table to support instance level anomaly
天舟d3403b4a138e
diff --git a/store/migration/10001__init_schema.sql b/store/migration/10001__init_schema.sqlindex 7cb834e9d6..b0a75d55dd 100644--- a/store/migration/10001__init_schema.sql+++ b/store/migration/10001__init_schema.sql@@ -1187,7 +1187,7 @@ END;-- Anomaly-- anomaly stores various anomalies found by the scanner.--- For now, anomaly is associated with a particular database. In the future, we may relax it a bit to have instance level anomalys.+-- For now, anomaly can be associated with a particular instance or database.CREATE TABLE anomaly (id INTEGER PRIMARY KEY AUTOINCREMENT,row_status TEXT NOT NULL CHECK (@@ -1198,11 +1198,13 @@ CREATE TABLE anomaly (updater_id INTEGER NOT NULL REFERENCES principal (id),updated_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')),instance_id INTEGER NOT NULL REFERENCES instance (id),- database_id INTEGER NOT NULL REFERENCES db (id),+ -- NULL if it's an instance anomaly+ database_id INTEGER NULL REFERENCES db (id),`type` TEXT NOT NULL CHECK (`type` LIKE 'bb.anomaly.%'),payload TEXT NOT NULL DEFAULT '');+CREATE INDEX idx_anomaly_instance_id_row_status_type ON anomaly(instance_id, row_status, type);CREATE INDEX idx_anomaly_database_id_row_status_type ON anomaly(database_id, row_status, type);INSERT INTO