Skip to content

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

chore: fix instance change history data (#11236)

Danny Xu4ba18209e1f0
diff --git a/backend/migrator/migration/prod/2.15/0002##pitr.sql b/backend/migrator/migration/prod/2.15/0002##pitr.sql
index 36306457f9..5448b5f56c 100644
--- a/backend/migrator/migration/prod/2.15/0002##pitr.sql
+++ b/backend/migrator/migration/prod/2.15/0002##pitr.sql
@@ -10,5 +10,7 @@ DELETE FROM task_dag;
DELETE FROM task_run WHERE task_id IN (SELECT id FROM task WHERE type = 'bb.task.database.backup' OR type = 'bb.task.database.restore.pitr.restore' OR type = 'bb.task.database.restore.pitr.cutover');
DELETE FROM task WHERE type = 'bb.task.database.backup' OR type = 'bb.task.database.restore.pitr.restore' OR type = 'bb.task.database.restore.pitr.cutover';
DELETE FROM stage WHERE NOT EXISTS (SELECT task.id FROM task WHERE task.stage_id = stage.id);
+DELETE FROM instance_change_history WHERE issue_id IN (SELECT id FROM issue WHERE NOT EXISTS (SELECT task.id FROM task WHERE task.pipeline_id = issue.pipeline_id) AND issue.type = 'bb.issue.database.general');
+DELETE FROM instance_change_history WHERE type = 'BRANCH';
DELETE FROM issue WHERE NOT EXISTS (SELECT task.id FROM task WHERE task.pipeline_id = issue.pipeline_id) AND issue.type = 'bb.issue.database.general';
DELETE FROM pipeline WHERE NOT EXISTS (SELECT task.id FROM task WHERE task.pipeline_id = pipeline.id);