From a260ae17b27aab1c88424934ade0c2d093a6c39e Mon Sep 17 00:00:00 2001 From: Yash Mehrotra Date: Sat, 2 Nov 2024 16:15:48 +0530 Subject: [PATCH] chore: handle config item deletion which are linked to components --- views/001_alter_deferred_tables.sql | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/views/001_alter_deferred_tables.sql b/views/001_alter_deferred_tables.sql index 293b474e..490927c7 100644 --- a/views/001_alter_deferred_tables.sql +++ b/views/001_alter_deferred_tables.sql @@ -79,6 +79,10 @@ BEGIN DELETE FROM check_config_relationships WHERE config_id IN (SELECT id FROM config_items_to_delete); + -- Components are independent so we just unset config_id + UPDATE components SET config_id = NULL + WHERE config_id IN (SELECT id FROM config_items_to_delete); + -- Finally, delete the config_items themselves DELETE FROM config_items WHERE id IN (SELECT id FROM config_items_to_delete);