9. complete chill_person_accompanying_period_origin table
This commit is contained in:
parent
44d24155a1
commit
396444790f
@ -82,11 +82,22 @@ INSERT INTO chill_person_accompanying_period_closingmotive (id, name, active, pa
|
||||
CROSS JOIN max_ordering
|
||||
WHERE NOT EXISTS ( SELECT 1 FROM chill_person_accompanying_period_closingmotive WHERE name::jsonb = t.closingmotive1 );
|
||||
|
||||
-- 9. Complete origin
|
||||
ALTER TABLE import.choix_periodes ADD COLUMN origin1 JSONB;
|
||||
UPDATE import.choix_periodes SET origin1=json_build_object('fr', trim(origin)) WHERE origin!='';
|
||||
INSERT INTO chill_person_accompanying_period_origin (id, label, noactiveafter)
|
||||
SELECT nextval('chill_person_accompanying_period_origin_id_seq'), t.origin1, null
|
||||
FROM ( SELECT DISTINCT ON (origin) origin1 FROM import.choix_periodes WHERE origin1 IS NOT NULL ) t
|
||||
WHERE NOT EXISTS ( SELECT 1 FROM chill_person_accompanying_period_origin WHERE label::jsonb = t.origin1 );
|
||||
|
||||
--
|
||||
-- DOWN
|
||||
--
|
||||
|
||||
-- Undo 9.
|
||||
DELETE FROM chill_person_accompanying_period_origin cpapo USING import.choix_periodes icp WHERE cpapo.label::jsonb = icp.origin1::jsonb;
|
||||
SELECT setval('chill_person_accompanying_period_origin_id_seq', (SELECT max(id) FROM chill_person_accompanying_period_origin));
|
||||
ALTER TABLE import.choix_periodes DROP COLUMN origin1;
|
||||
|
||||
-- Undo 8.
|
||||
DELETE FROM chill_person_accompanying_period_closingmotive cpapcm USING import.choix_periodes icp WHERE cpapcm.name::jsonb = icp.closingmotive1::jsonb;
|
||||
|
Loading…
Reference in New Issue
Block a user