aboutsummaryrefslogtreecommitdiff
path: root/sqitch/deploy/builds_add_derivation_output_details_set_id.sql
blob: 692e25c8264f4f951ae10b5722e959c484e75c3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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;