aboutsummaryrefslogtreecommitdiff
path: root/sqitch
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2020-10-02 18:14:40 +0100
committerChristopher Baines <mail@cbaines.net>2020-10-02 20:15:10 +0100
commit841f5fb18697a545f083e48e2b1e3ab47e4312e4 (patch)
tree2cbf1d634873b77bbf3f01bcffb01ae9a034ae29 /sqitch
parent125a35fce557ed0c73872944c04ec39d10b4ca1c (diff)
downloaddata-service-841f5fb18697a545f083e48e2b1e3ab47e4312e4.tar
data-service-841f5fb18697a545f083e48e2b1e3ab47e4312e4.tar.gz
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.
Diffstat (limited to 'sqitch')
-rw-r--r--sqitch/deploy/change_derivation_source_file_nars_constraint.sql13
-rw-r--r--sqitch/revert/change_derivation_source_file_nars_constraint.sql7
-rw-r--r--sqitch/sqitch.plan1
-rw-r--r--sqitch/verify/change_derivation_source_file_nars_constraint.sql7
4 files changed, 28 insertions, 0 deletions
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 <daniela@linux-ijv5> # Add
change_package_descriptions_index 2020-08-23T11:56:00Z Christopher Baines <mail@cbaines.net> # Change the package_descriptions index
change_locale_values 2020-09-26T10:20:22Z Christopher Baines <mail@cbaines.net> # Change locale values
change_autovacuum_config 2020-10-01T21:24:46Z Christopher Baines <mail@cbaines.net> # Change autovacuum config
+change_derivation_source_file_nars_constraint 2020-10-02T17:12:58Z Christopher Baines <mail@cbaines.net> # 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;