From 1461aa037fa64b3b4694428a1e00239f3f592ff5 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Tue, 1 Aug 2023 14:12:48 +0100 Subject: Make database changes to help with deleting entries in the nars table --- sqitch/deploy/cascade_nar_foreign_keys.sql | 35 ++++++++++++++++++++++++++++++ sqitch/deploy/nar_indexes.sql | 9 ++++++++ sqitch/revert/cascade_nar_foreign_keys.sql | 7 ++++++ sqitch/revert/nar_indexes.sql | 7 ++++++ sqitch/sqitch.plan | 2 ++ sqitch/verify/cascade_nar_foreign_keys.sql | 7 ++++++ sqitch/verify/nar_indexes.sql | 7 ++++++ 7 files changed, 74 insertions(+) create mode 100644 sqitch/deploy/cascade_nar_foreign_keys.sql create mode 100644 sqitch/deploy/nar_indexes.sql create mode 100644 sqitch/revert/cascade_nar_foreign_keys.sql create mode 100644 sqitch/revert/nar_indexes.sql create mode 100644 sqitch/verify/cascade_nar_foreign_keys.sql create mode 100644 sqitch/verify/nar_indexes.sql (limited to 'sqitch') 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; diff --git a/sqitch/revert/cascade_nar_foreign_keys.sql b/sqitch/revert/cascade_nar_foreign_keys.sql new file mode 100644 index 0000000..2e9d7f3 --- /dev/null +++ b/sqitch/revert/cascade_nar_foreign_keys.sql @@ -0,0 +1,7 @@ +-- Revert guix-data-service:cascade_nar_foreign_keys from pg + +BEGIN; + +-- XXX Add DDLs here. + +COMMIT; diff --git a/sqitch/revert/nar_indexes.sql b/sqitch/revert/nar_indexes.sql new file mode 100644 index 0000000..f98c6b8 --- /dev/null +++ b/sqitch/revert/nar_indexes.sql @@ -0,0 +1,7 @@ +-- Revert guix-data-service:nar_indexes from pg + +BEGIN; + +-- XXX Add DDLs here. + +COMMIT; diff --git a/sqitch/sqitch.plan b/sqitch/sqitch.plan index caab662..a3f8952 100644 --- a/sqitch/sqitch.plan +++ b/sqitch/sqitch.plan @@ -94,3 +94,5 @@ package_derivations_extended_statistics 2022-11-12T10:40:18Z Chris derivation_outputs_id_and_derivation_id_idx 2022-11-12T10:41:42Z Chris # Add index on derivation_outputs id and derivation_id blocked_builds_blocked_builds_blocked_derivation_output_details_set_id_2 2023-03-05T10:19:53Z Chris # Add index on blocked_builds_blocked_derivation_output_details_set_id guix_revision_package_derivation_distribution_counts 2023-03-08T16:53:44Z Chris # Add guix_revision_package_derivation_distribution_counts table +cascade_nar_foreign_keys 2023-08-01T09:42:33Z Chris # Make it easier to delete nars entries +nar_indexes 2023-08-01T11:37:35Z Chris # Add nar related indexes diff --git a/sqitch/verify/cascade_nar_foreign_keys.sql b/sqitch/verify/cascade_nar_foreign_keys.sql new file mode 100644 index 0000000..f292949 --- /dev/null +++ b/sqitch/verify/cascade_nar_foreign_keys.sql @@ -0,0 +1,7 @@ +-- Verify guix-data-service:cascade_nar_foreign_keys on pg + +BEGIN; + +-- XXX Add verifications here. + +ROLLBACK; diff --git a/sqitch/verify/nar_indexes.sql b/sqitch/verify/nar_indexes.sql new file mode 100644 index 0000000..3e2f519 --- /dev/null +++ b/sqitch/verify/nar_indexes.sql @@ -0,0 +1,7 @@ +-- Verify guix-data-service:nar_indexes on pg + +BEGIN; + +-- XXX Add verifications here. + +ROLLBACK; -- cgit v1.2.3