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 $$;