guix-data-service/sqitch/deploy/change_derivation_source_file_nars_constraint.sql
Christopher Baines 841f5fb186 Change a constraint to add ON DELETE CASCADE
I've not used these in many places, to try and avoid hiding deleting data, but
in this case, this will allow more easily deleting the derivation source file
nars, by just deleting the derivation_source_files table entry.
2020-10-02 20:15:10 +01:00

13 lines
435 B
PL/PgSQL

-- Deploy guix-data-service:change_derivation_source_file_nars_constraint to pg
BEGIN;
ALTER TABLE derivation_source_file_nars
DROP CONSTRAINT derivation_source_file_nars_derivation_source_file_id_fkey;
ALTER TABLE derivation_source_file_nars
ADD CONSTRAINT derivation_source_file_nars_derivation_source_file_id_fkey
FOREIGN KEY (derivation_source_file_id) REFERENCES derivation_source_files(id)
ON DELETE CASCADE;
COMMIT;