From c8b93cb0d02abfbf0a8162ed221b9fac83fed715 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sat, 7 Dec 2019 19:27:31 +0100 Subject: Add new derivation_output_details_set_id column to the builds table As this will hopefully provide a faster way of associating derivations with builds. --- ...builds_add_derivation_output_details_set_id.sql | 22 ++++++++++++++++++++++ ...builds_add_derivation_output_details_set_id.sql | 7 +++++++ sqitch/sqitch.plan | 1 + ...builds_add_derivation_output_details_set_id.sql | 7 +++++++ 4 files changed, 37 insertions(+) create mode 100644 sqitch/deploy/builds_add_derivation_output_details_set_id.sql create mode 100644 sqitch/revert/builds_add_derivation_output_details_set_id.sql create mode 100644 sqitch/verify/builds_add_derivation_output_details_set_id.sql (limited to 'sqitch') diff --git a/sqitch/deploy/builds_add_derivation_output_details_set_id.sql b/sqitch/deploy/builds_add_derivation_output_details_set_id.sql new file mode 100644 index 0000000..692e25c --- /dev/null +++ b/sqitch/deploy/builds_add_derivation_output_details_set_id.sql @@ -0,0 +1,22 @@ +-- Deploy guix-data-service:builds_add_derivation_output_details_set_id to pg + +BEGIN; + +ALTER TABLE builds + ADD COLUMN derivation_output_details_set_id integer + NULL + DEFAULT NULL + REFERENCES derivation_output_details_sets (id); + +UPDATE builds SET derivation_output_details_set_id = ( + SELECT derivations_by_output_details_set.derivation_output_details_set_id + FROM derivations_by_output_details_set + INNER JOIN derivations + ON derivations.file_name = builds.derivation_file_name + WHERE derivations_by_output_details_set.derivation_id = derivations.id +); + +CREATE INDEX builds_derivation_output_details_set_id ON + builds (derivation_output_details_set_id); + +COMMIT; diff --git a/sqitch/revert/builds_add_derivation_output_details_set_id.sql b/sqitch/revert/builds_add_derivation_output_details_set_id.sql new file mode 100644 index 0000000..97a5954 --- /dev/null +++ b/sqitch/revert/builds_add_derivation_output_details_set_id.sql @@ -0,0 +1,7 @@ +-- Revert guix-data-service:builds_add_derivation_output_details_set_id from pg + +BEGIN; + +-- XXX Add DDLs here. + +COMMIT; diff --git a/sqitch/sqitch.plan b/sqitch/sqitch.plan index 2f5b512..c047adf 100644 --- a/sqitch/sqitch.plan +++ b/sqitch/sqitch.plan @@ -37,3 +37,4 @@ change_nar_urls_size_to_bigint 2019-12-04T21:49:07Z # Change nar sort_out_duplicate_builds 2019-12-05T12:43:53Z # Sort out duplicate builds add_some_database_indexes 2019-12-05T15:53:04Z Christopher Baines # Add some indexes derivation_output_sets 2019-12-05T23:19:05Z Christopher Baines # Describe the sets of derivation outputs +builds_add_derivation_output_details_set_id 2019-12-07T18:25:38Z Christopher Baines # Add a derivation_output_details_set_id column to builds diff --git a/sqitch/verify/builds_add_derivation_output_details_set_id.sql b/sqitch/verify/builds_add_derivation_output_details_set_id.sql new file mode 100644 index 0000000..fc91296 --- /dev/null +++ b/sqitch/verify/builds_add_derivation_output_details_set_id.sql @@ -0,0 +1,7 @@ +-- Verify guix-data-service:builds_add_derivation_output_details_set_id on pg + +BEGIN; + +-- XXX Add verifications here. + +ROLLBACK; -- cgit v1.2.3