aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2019-12-05 14:09:06 +0100
committerChristopher Baines <mail@cbaines.net>2019-12-05 15:40:42 +0100
commit3f3801d0dde9ffe83eec2789dbaf8c4be40a9280 (patch)
treee02a66804c5241ce8a9a502aeb02232ca15b2427
parent76eca407910ce8ca714291c74dec8d9761590d56 (diff)
downloaddata-service-3f3801d0dde9ffe83eec2789dbaf8c4be40a9280.tar
data-service-3f3801d0dde9ffe83eec2789dbaf8c4be40a9280.tar.gz
WIP equivalent derivations
-rw-r--r--sqitch/deploy/equivalent_derivations.sql17
-rw-r--r--sqitch/revert/equivalent_derivations.sql7
-rw-r--r--sqitch/sqitch.plan1
-rw-r--r--sqitch/verify/equivalent_derivations.sql7
4 files changed, 32 insertions, 0 deletions
diff --git a/sqitch/deploy/equivalent_derivations.sql b/sqitch/deploy/equivalent_derivations.sql
new file mode 100644
index 0000000..3ec6ca0
--- /dev/null
+++ b/sqitch/deploy/equivalent_derivations.sql
@@ -0,0 +1,17 @@
+-- Deploy guix-data-service:equivalent_derivations to pg
+
+BEGIN;
+
+CREATE TABLE equivalent_derivations AS
+ SELECT ARRAY_AGG(derivation_id ORDER BY derivation_id ASC) AS derivation_ids,
+ derivation_output_details_ids
+ FROM (
+ SELECT derivation_id, ARRAY_AGG(derivation_output_details_id ORDER BY derivation_output_details_id) AS derivation_output_details_ids
+ FROM derivation_outputs
+ GROUP BY derivation_id
+ ) AS derivation_output_groups
+ GROUP BY derivation_output_groups.derivation_output_details_ids;
+
+CREATE INDEX equivalent_derivations_derivation_ids ON equivalent_derivations USING GIN (derivation_ids);
+
+COMMIT;
diff --git a/sqitch/revert/equivalent_derivations.sql b/sqitch/revert/equivalent_derivations.sql
new file mode 100644
index 0000000..cf9a995
--- /dev/null
+++ b/sqitch/revert/equivalent_derivations.sql
@@ -0,0 +1,7 @@
+-- Revert guix-data-service:equivalent_derivations from pg
+
+BEGIN;
+
+-- XXX Add DDLs here.
+
+COMMIT;
diff --git a/sqitch/sqitch.plan b/sqitch/sqitch.plan
index 3b16f94..158adab 100644
--- a/sqitch/sqitch.plan
+++ b/sqitch/sqitch.plan
@@ -32,3 +32,4 @@ rework_builds 2019-11-23T20:41:20Z Christopher Baines <mail@cbaines.net> # Rewor
nar_related_tables 2019-11-29T20:28:19Z Christopher Baines <mail@cbaines.net> # Add nar related tables
add_index_on_builds_derivation_file_name 2019-12-03T16:23:55Z <chris@phact> # Add index on builds_derivation_file_name
narinfo_fetch_record 2019-12-03T20:53:28Z <chris@phact> # Add a table to describe fetching a narinfo
+equivalent_derivations 2019-12-04T16:43:37Z <chris@phact> # Add equivalent_derivations table
diff --git a/sqitch/verify/equivalent_derivations.sql b/sqitch/verify/equivalent_derivations.sql
new file mode 100644
index 0000000..58fafed
--- /dev/null
+++ b/sqitch/verify/equivalent_derivations.sql
@@ -0,0 +1,7 @@
+-- Verify guix-data-service:equivalent_derivations on pg
+
+BEGIN;
+
+-- XXX Add verifications here.
+
+ROLLBACK;