diff --git a/packages/db/migrations/0107.do.grant_delete_permission_on_subscription.sql b/packages/db/migrations/0107.do.grant_delete_permission_on_subscription.sql new file mode 100755 index 000000000..1185d21d1 --- /dev/null +++ b/packages/db/migrations/0107.do.grant_delete_permission_on_subscription.sql @@ -0,0 +1,16 @@ +-- Type: DO +-- Name: add_delete_permission_to_subscription +-- Description: Add delete permission to subscription table + +BEGIN; + +GRANT DELETE ON omnivore.subscriptions TO omnivore_user; + +ALTER TABLE omnivore.subscriptions + DROP CONSTRAINT subscriptions_newsletter_email_id_fkey, + ADD CONSTRAINT subscriptions_newsletter_email_id_fkey + FOREIGN KEY (newsletter_email_id) + REFERENCES omnivore.newsletter_emails (id) + ON DELETE CASCADE; + +COMMIT; diff --git a/packages/db/migrations/0107.undo.grant_delete_permission_on_subscription.sql b/packages/db/migrations/0107.undo.grant_delete_permission_on_subscription.sql new file mode 100755 index 000000000..e7cb3c0ba --- /dev/null +++ b/packages/db/migrations/0107.undo.grant_delete_permission_on_subscription.sql @@ -0,0 +1,15 @@ +-- Type: UNDO +-- Name: add_delete_permission_to_subscription +-- Description: Add delete permission to subscription table + +BEGIN; + +REVOKE DELETE ON omnivore.subscriptions FROM omnivore_user; + +ALTER TABLE omnivore.subscriptions + DROP CONSTRAINT subscriptions_newsletter_email_id_fkey, + ADD CONSTRAINT subscriptions_newsletter_email_id_fkey + FOREIGN KEY (newsletter_email_id) + REFERENCES omnivore.newsletter_emails (id); + +COMMIT;