From c5a9007721129b88d747ccffb20b85aa712a556d Mon Sep 17 00:00:00 2001 From: Lucas Magnus Date: Wed, 6 Dec 2023 10:22:45 -0300 Subject: [PATCH] fix migration down --- .../000035_add_contract_permissions.down.sql | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/backend/migrations/000035_add_contract_permissions.down.sql b/backend/migrations/000035_add_contract_permissions.down.sql index a48a469b..7cbb9c77 100644 --- a/backend/migrations/000035_add_contract_permissions.down.sql +++ b/backend/migrations/000035_add_contract_permissions.down.sql @@ -1 +1,22 @@ -DROP TABLE IF EXISTS Contracts; \ No newline at end of file +DO $$ +DECLARE + permission_id INT; +BEGIN + -- Revert 'Invest in the certificate' + SELECT id INTO permission_id FROM Permission WHERE name = 'Invest in the certificate'; + DELETE FROM RolePermissionJunction WHERE permission_id = permission_id; + DELETE FROM Operation WHERE permission_id = permission_id; + DELETE FROM Permission WHERE id = permission_id; + + -- Revert 'Create wallet' + SELECT id INTO permission_id FROM Permission WHERE name = 'Create wallet'; + DELETE FROM RolePermissionJunction WHERE permission_id = permission_id; + DELETE FROM Operation WHERE permission_id = permission_id; + DELETE FROM Permission WHERE id = permission_id; + + -- Revert 'Create certificates' + SELECT id INTO permission_id FROM Permission WHERE name = 'Create certificates'; + DELETE FROM RolePermissionJunction WHERE permission_id = permission_id; + DELETE FROM Operation WHERE permission_id = permission_id; + DELETE FROM Permission WHERE id = permission_id; +END $$;