Skip to content

Commit

Permalink
Set ON DELETE CASCADE for sessions referencing clients
Browse files Browse the repository at this point in the history
  • Loading branch information
rien committed Oct 26, 2023
1 parent d668529 commit 00fa4d2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions migrations/2023-10-26-0942_session_delete_cascade/down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- This file should undo anything in `up.sql`

ALTER TABLE sessions
DROP CONSTRAINT sessions_client_id_fkey,
ADD CONSTRAINT sessions_client_id_fkey
FOREIGN KEY (client_id)
REFERENCES clients(id)
ON DELETE NO ACTION;
8 changes: 8 additions & 0 deletions migrations/2023-10-26-0942_session_delete_cascade/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- Your SQL goes here

ALTER TABLE sessions
DROP CONSTRAINT sessions_client_id_fkey,
ADD CONSTRAINT sessions_client_id_fkey
FOREIGN KEY (client_id)
REFERENCES clients(id)
ON DELETE CASCADE;

0 comments on commit 00fa4d2

Please sign in to comment.