10. complete chill_main_user_job table
This commit is contained in:
parent
396444790f
commit
6d64060965
@ -38,7 +38,7 @@ INSERT INTO chill_main_civility (id, name, abbreviation, active, ordering)
|
|||||||
ALTER TABLE import.choix_personnes ADD COLUMN country1 JSONB;
|
ALTER TABLE import.choix_personnes ADD COLUMN country1 JSONB;
|
||||||
UPDATE import.choix_personnes SET country1=json_build_object('fr', trim(country)) WHERE country!='';
|
UPDATE import.choix_personnes SET country1=json_build_object('fr', trim(country)) WHERE country!='';
|
||||||
INSERT INTO country (id, name, countrycode)
|
INSERT INTO country (id, name, countrycode)
|
||||||
SELECT nextval('country_id_seq'), t.country1, 'ZZZ'
|
SELECT nextval('country_id_seq'), t.country1, 'ZZ'
|
||||||
FROM ( SELECT DISTINCT ON (country) country1 FROM import.choix_personnes WHERE country1 IS NOT NULL ) t
|
FROM ( SELECT DISTINCT ON (country) country1 FROM import.choix_personnes WHERE country1 IS NOT NULL ) t
|
||||||
WHERE NOT EXISTS ( SELECT 1 FROM country WHERE name::jsonb = t.country1 );
|
WHERE NOT EXISTS ( SELECT 1 FROM country WHERE name::jsonb = t.country1 );
|
||||||
|
|
||||||
@ -90,10 +90,28 @@ INSERT INTO chill_person_accompanying_period_origin (id, label, noactiveafter)
|
|||||||
FROM ( SELECT DISTINCT ON (origin) origin1 FROM import.choix_periodes WHERE origin1 IS NOT NULL ) t
|
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 );
|
WHERE NOT EXISTS ( SELECT 1 FROM chill_person_accompanying_period_origin WHERE label::jsonb = t.origin1 );
|
||||||
|
|
||||||
|
-- 10. Complete user_job
|
||||||
|
ALTER TABLE import.choix_periodes ADD COLUMN job1 JSONB;
|
||||||
|
UPDATE import.choix_periodes SET job1=json_build_object('fr', trim(job)) WHERE job!='';
|
||||||
|
INSERT INTO chill_main_user_job (id, label, active)
|
||||||
|
SELECT nextval('chill_main_user_job_id_seq'), t.job1, true
|
||||||
|
FROM ( SELECT DISTINCT ON (job) job1 FROM import.choix_periodes WHERE job1 IS NOT NULL ) t
|
||||||
|
WHERE NOT EXISTS( SELECT 1 FROM chill_main_user_job WHERE label::jsonb = t.job1 );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- DOWN
|
-- DOWN
|
||||||
--
|
--
|
||||||
|
|
||||||
|
|
||||||
|
-- Undo 10.
|
||||||
|
DELETE FROM chill_main_user_job cmuj USING import.choix_periodes icp WHERE cmuj.label::jsonb = icp.job1::jsonb;
|
||||||
|
SELECT setval('chill_main_user_job_id_seq', (SELECT max(id) FROM chill_main_user_job));
|
||||||
|
ALTER TABLE import.choix_periodes DROP COLUMN job1;
|
||||||
|
|
||||||
-- Undo 9.
|
-- Undo 9.
|
||||||
DELETE FROM chill_person_accompanying_period_origin cpapo USING import.choix_periodes icp WHERE cpapo.label::jsonb = icp.origin1::jsonb;
|
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));
|
SELECT setval('chill_person_accompanying_period_origin_id_seq', (SELECT max(id) FROM chill_person_accompanying_period_origin));
|
||||||
|
Loading…
Reference in New Issue
Block a user