From 841f5fb18697a545f083e48e2b1e3ab47e4312e4 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Fri, 2 Oct 2020 18:14:40 +0100 Subject: 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. --- .../change_derivation_source_file_nars_constraint.sql | 13 +++++++++++++ .../change_derivation_source_file_nars_constraint.sql | 7 +++++++ sqitch/sqitch.plan | 1 + .../change_derivation_source_file_nars_constraint.sql | 7 +++++++ 4 files changed, 28 insertions(+) create mode 100644 sqitch/deploy/change_derivation_source_file_nars_constraint.sql create mode 100644 sqitch/revert/change_derivation_source_file_nars_constraint.sql create mode 100644 sqitch/verify/change_derivation_source_file_nars_constraint.sql (limited to 'sqitch') diff --git a/sqitch/deploy/change_derivation_source_file_nars_constraint.sql b/sqitch/deploy/change_derivation_source_file_nars_constraint.sql new file mode 100644 index 0000000..b8e96a2 --- /dev/null +++ b/sqitch/deploy/change_derivation_source_file_nars_constraint.sql @@ -0,0 +1,13 @@ +-- 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; diff --git a/sqitch/revert/change_derivation_source_file_nars_constraint.sql b/sqitch/revert/change_derivation_source_file_nars_constraint.sql new file mode 100644 index 0000000..a2143f8 --- /dev/null +++ b/sqitch/revert/change_derivation_source_file_nars_constraint.sql @@ -0,0 +1,7 @@ +-- Revert guix-data-service:change_derivation_source_file_nars_constraint from pg + +BEGIN; + +-- XXX Add DDLs here. + +COMMIT; diff --git a/sqitch/sqitch.plan b/sqitch/sqitch.plan index 95d0392..09df4bb 100644 --- a/sqitch/sqitch.plan +++ b/sqitch/sqitch.plan @@ -70,3 +70,4 @@ add-tsvectors-per-locale 2020-07-16T18:19:44Z daniela # Add change_package_descriptions_index 2020-08-23T11:56:00Z Christopher Baines # Change the package_descriptions index change_locale_values 2020-09-26T10:20:22Z Christopher Baines # Change locale values change_autovacuum_config 2020-10-01T21:24:46Z Christopher Baines # Change autovacuum config +change_derivation_source_file_nars_constraint 2020-10-02T17:12:58Z Christopher Baines # Change derivation source file nars constraint diff --git a/sqitch/verify/change_derivation_source_file_nars_constraint.sql b/sqitch/verify/change_derivation_source_file_nars_constraint.sql new file mode 100644 index 0000000..7c00429 --- /dev/null +++ b/sqitch/verify/change_derivation_source_file_nars_constraint.sql @@ -0,0 +1,7 @@ +-- Verify guix-data-service:change_derivation_source_file_nars_constraint on pg + +BEGIN; + +-- XXX Add verifications here. + +ROLLBACK; -- cgit v1.2.3