Skip to content

Commit

Permalink
fix migration down
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmagnus committed Dec 6, 2023
1 parent 9f97b83 commit c5a9007
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion backend/migrations/000035_add_contract_permissions.down.sql
Original file line number Diff line number Diff line change
@@ -1 +1,22 @@
DROP TABLE IF EXISTS Contracts;
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 $$;

0 comments on commit c5a9007

Please sign in to comment.