dbjobqueue: Alter foreign key constraints

When deleting rows from the job table, make sure the delete is cascaded
to the dependencies and heartbeat tables.
This commit is contained in:
Sanne Raymaekers 2022-06-01 10:25:27 +02:00
parent feb357e538
commit 9bff4a4f0f
2 changed files with 17 additions and 0 deletions

View file

@ -0,0 +1,11 @@
ALTER TABLE job_dependencies
DROP CONSTRAINT job_dependencies_dependency_id_fkey,
DROP CONSTRAINT job_dependencies_job_id_fkey,
ADD CONSTRAINT job_dependencies_dependency_id_fkey
FOREIGN KEY (job_id) REFERENCES jobs(id) ON DELETE CASCADE,
ADD CONSTRAINT job_dependencies_job_id_fkey
FOREIGN KEY (dependency_id) REFERENCES jobs(id) ON DELETE CASCADE;

View file

@ -0,0 +1,6 @@
ALTER TABLE heartbeats
DROP CONSTRAINT heartbeats_id_fkey,
ADD CONSTRAINT heartbeats_id_fkey
FOREIGN KEY (id) REFERENCES jobs(id) ON DELETE CASCADE;