Skip to content

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

fix: delete dirty data (#11015)

ecmadaod2f5f15d8c50
diff --git a/backend/migrator/migration/prod/2.14/0001##worksheet.sql b/backend/migrator/migration/prod/2.14/0001##worksheet.sql
index 27a4184529..6c721275ba 100644
--- a/backend/migrator/migration/prod/2.14/0001##worksheet.sql
+++ b/backend/migrator/migration/prod/2.14/0001##worksheet.sql
@@ -41,6 +41,7 @@ FROM sheet
WHERE sheet.source = 'BYTEBASE';
-- Change fk for sheet_organizer.
+DELETE FROM sheet_organizer USING sheet WHERE sheet_organizer.sheet_id = sheet.id AND sheet.source != 'BYTEBASE';
ALTER TABLE sheet_organizer DROP CONSTRAINT sheet_organizer_sheet_id_fkey;
ALTER TABLE sheet_organizer ADD CONSTRAINT sheet_organizer_sheet_id_fkey FOREIGN KEY (sheet_id) REFERENCES worksheet (id);