blob: f7259f05fc0a71f8453a4bab172a775ff350c5cb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
-- Deploy guix-data-service:systems_table to pg
BEGIN;
CREATE TABLE systems (
id integer PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
system character varying UNIQUE NOT NULL
);
INSERT INTO systems (system) SELECT DISTINCT system FROM derivations;
ALTER TABLE derivations
ADD COLUMN system_id integer REFERENCES systems (id);
UPDATE derivations
SET system_id = (
SELECT id FROM systems WHERE systems.system = derivations.system
);
ALTER TABLE derivations
ALTER COLUMN system_id SET NOT NULL;
ALTER TABLE derivations DROP COLUMN system;
ALTER TABLE package_derivations
ADD COLUMN system_id integer REFERENCES systems (id);
UPDATE package_derivations
SET system_id = (
SELECT id FROM systems WHERE systems.system = package_derivations.system
);
ALTER TABLE package_derivations
ALTER COLUMN system_id SET NOT NULL;
ALTER TABLE package_derivations DROP COLUMN system;
COMMIT;
|