Skip to content

Commit

Permalink
CORE-1906: automatically delete job steps when the corresponding job …
Browse files Browse the repository at this point in the history
…is deleted
  • Loading branch information
slr71 committed Jun 7, 2023
1 parent 9e999dc commit 05e9b09
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
19 changes: 19 additions & 0 deletions migrations/000036_job_steps_fkey.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
BEGIN;

SET search_path = public, pg_catalog;

--
-- Remove the foreign key if it already exists.
--
ALTER TABLE IF EXISTS job_steps
DROP CONSTRAINT job_steps_job_id_fkey;

--
-- Add the foreign key back to the table without the cascade.
--
ALTER TABLE IF EXISTS job_steps
ADD CONSTRAINT job_steps_job_id_fkey
FOREIGN KEY (job_id)
REFERENCES jobs (id);

COMMIT;
19 changes: 19 additions & 0 deletions migrations/000036_job_steps_fkey.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
BEGIN;

SET search_path = public, pg_catalog;

--
-- Remove the foreign key if it already exists.
--
ALTER TABLE IF EXISTS job_steps
DROP CONSTRAINT job_steps_job_id_fkey;

--
-- Add the foreign key back to the table with the cascade.
--
ALTER TABLE IF EXISTS job_steps
ADD CONSTRAINT job_steps_job_id_fkey
FOREIGN KEY (job_id)
REFERENCES jobs (id) ON DELETE CASCADE;

COMMIT;

0 comments on commit 05e9b09

Please sign in to comment.