From 0ca5d7223a2b3939ac4007fbc975652b29718579 Mon Sep 17 00:00:00 2001 From: Viswas Date: Tue, 10 Dec 2024 19:50:40 +0530 Subject: [PATCH 1/2] fix: raise notice to delete dependent fields after workspace reset --- scripts/sql/functions/delete-workspace.sql | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/sql/functions/delete-workspace.sql b/scripts/sql/functions/delete-workspace.sql index f6e5db6f..79ec337f 100644 --- a/scripts/sql/functions/delete-workspace.sql +++ b/scripts/sql/functions/delete-workspace.sql @@ -327,6 +327,17 @@ BEGIN RAISE NOTICE E'\n\n\n\n\n\n\n\n\nSwitch to prod db and run the below query to update the subscription'; RAISE NOTICE E'begin; update platform_schema.admin_subscriptions set is_enabled = false where org_id = ''%'';\n\n\n\n\n\n\n\n\n\n\n', _org_id; + RAISE NOTICE E'\n\n\n\n\n\n\n\n\nSwitch to prod db and run the below queries to delete dependent fields + + +rollback; +begin; + +delete from platform_schema.dependent_expense_field_mappings where expense_field_id in (select id from platform_schema.expense_fields where org_id =''%'' and type=''DEPENDENT_SELECT''); + +delete from platform_schema.expense_fields where org_id = ''%'' and type = ''DEPENDENT_SELECT'';\n\n\n\n\n\n\n\n\n\n\n', _org_id, _org_id; + + RETURN; END $$ LANGUAGE plpgsql; From 0423550315e6a81c599befb828a83a30005729cf Mon Sep 17 00:00:00 2001 From: Viswas Date: Tue, 10 Dec 2024 20:50:09 +0530 Subject: [PATCH 2/2] refactor: squish query to a one-liner --- scripts/sql/functions/delete-workspace.sql | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/scripts/sql/functions/delete-workspace.sql b/scripts/sql/functions/delete-workspace.sql index 79ec337f..ce6ea848 100644 --- a/scripts/sql/functions/delete-workspace.sql +++ b/scripts/sql/functions/delete-workspace.sql @@ -327,15 +327,8 @@ BEGIN RAISE NOTICE E'\n\n\n\n\n\n\n\n\nSwitch to prod db and run the below query to update the subscription'; RAISE NOTICE E'begin; update platform_schema.admin_subscriptions set is_enabled = false where org_id = ''%'';\n\n\n\n\n\n\n\n\n\n\n', _org_id; - RAISE NOTICE E'\n\n\n\n\n\n\n\n\nSwitch to prod db and run the below queries to delete dependent fields - - -rollback; -begin; - -delete from platform_schema.dependent_expense_field_mappings where expense_field_id in (select id from platform_schema.expense_fields where org_id =''%'' and type=''DEPENDENT_SELECT''); - -delete from platform_schema.expense_fields where org_id = ''%'' and type = ''DEPENDENT_SELECT'';\n\n\n\n\n\n\n\n\n\n\n', _org_id, _org_id; + RAISE NOTICE E'\n\n\n\n\n\n\n\n\nSwitch to prod db and run the below queries to delete dependent fields'; + RAISE NOTICE E'rollback;begin; delete from platform_schema.dependent_expense_field_mappings where expense_field_id in (select id from platform_schema.expense_fields where org_id =''%'' and type=''DEPENDENT_SELECT''); delete from platform_schema.expense_fields where org_id = ''%'' and type = ''DEPENDENT_SELECT'';\n\n\n\n\n\n\n\n\n\n\n', _org_id, _org_id; RETURN;