aboutsummaryrefslogtreecommitdiff
path: root/sqitch/deploy
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2023-08-01 14:12:48 +0100
committerChristopher Baines <mail@cbaines.net>2023-08-01 14:12:48 +0100
commit1461aa037fa64b3b4694428a1e00239f3f592ff5 (patch)
tree38ec3c802e2d15c8f9d18316449fc25ecbe1e622 /sqitch/deploy
parent7495085f631a3589ecdf5f282b750a318b422394 (diff)
downloaddata-service-1461aa037fa64b3b4694428a1e00239f3f592ff5.tar
data-service-1461aa037fa64b3b4694428a1e00239f3f592ff5.tar.gz
Make database changes to help with deleting entries in the nars table
Diffstat (limited to 'sqitch/deploy')
-rw-r--r--sqitch/deploy/cascade_nar_foreign_keys.sql35
-rw-r--r--sqitch/deploy/nar_indexes.sql9
2 files changed, 44 insertions, 0 deletions
diff --git a/sqitch/deploy/cascade_nar_foreign_keys.sql b/sqitch/deploy/cascade_nar_foreign_keys.sql
new file mode 100644
index 0000000..8e01139
--- /dev/null
+++ b/sqitch/deploy/cascade_nar_foreign_keys.sql
@@ -0,0 +1,35 @@
+-- Deploy guix-data-service:cascade_nar_foreign_keys to pg
+
+BEGIN;
+
+ALTER TABLE narinfo_fetch_records
+ DROP CONSTRAINT narinfo_fetch_records_narinfo_signature_data_id_fkey,
+ ADD CONSTRAINT narinfo_fetch_records_narinfo_signature_data_id_fkey
+ FOREIGN KEY (narinfo_signature_data_id) REFERENCES narinfo_signature_data(id)
+ ON DELETE CASCADE;
+
+ALTER TABLE narinfo_signatures
+ DROP CONSTRAINT narinfo_signatures_nar_id_fkey,
+ ADD CONSTRAINT narinfo_signatures_nar_id_fkey
+ FOREIGN KEY (nar_id) REFERENCES nars(id)
+ ON DELETE CASCADE;
+
+ALTER TABLE narinfo_signatures
+ DROP CONSTRAINT narinfo_signatures_narinfo_signature_data_id_fkey,
+ ADD CONSTRAINT narinfo_signatures_narinfo_signature_data_id_fkey
+ FOREIGN KEY (narinfo_signature_data_id) REFERENCES narinfo_signature_data(id)
+ ON DELETE CASCADE;
+
+ALTER TABLE nar_references
+ DROP CONSTRAINT "nar_references_nar_id_fkey",
+ ADD CONSTRAINT "nar_references_nar_id_fkey"
+ FOREIGN KEY (nar_id) REFERENCES nars(id)
+ ON DELETE CASCADE;
+
+ALTER TABLE nar_urls
+ DROP CONSTRAINT "nar_urls_nar_id_fkey",
+ ADD CONSTRAINT "nar_urls_nar_id_fkey"
+ FOREIGN KEY (nar_id) REFERENCES nars(id)
+ ON DELETE CASCADE;
+
+COMMIT;
diff --git a/sqitch/deploy/nar_indexes.sql b/sqitch/deploy/nar_indexes.sql
new file mode 100644
index 0000000..baaeb00
--- /dev/null
+++ b/sqitch/deploy/nar_indexes.sql
@@ -0,0 +1,9 @@
+-- Deploy guix-data-service:nar_indexes to pg
+
+BEGIN;
+
+CREATE INDEX narinfo_signatures_narinfo_signature_data_id ON narinfo_signatures (narinfo_signature_data_id);;;;
+
+CREATE INDEX nar_references_nar_id ON nar_references (nar_id);
+
+COMMIT;