5. complete chill_person_marital_status table
This commit is contained in:
parent
40ebabf3f6
commit
27ef1034be
@ -42,14 +42,23 @@ SELECT nextval('country_id_seq'), t.country1, 'ZZZ'
|
|||||||
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 );
|
||||||
|
|
||||||
|
-- 5. Complete table maritalstatus
|
||||||
|
ALTER TABLE import.choix_personnes ADD COLUMN maritalstatus1 JSONB;
|
||||||
|
UPDATE import.choix_personnes SET maritalstatus1=json_build_object('fr', trim(maritalstatus)) WHERE maritalstatus!='';
|
||||||
|
INSERT INTO chill_person_marital_status (id, name)
|
||||||
|
SELECT substr(md5(random()::text), 1, 7), t.maritalstatus1
|
||||||
|
FROM ( SELECT DISTINCT ON (maritalstatus) maritalstatus1 FROM import.choix_personnes WHERE maritalstatus1 IS NOT NULL ) t
|
||||||
|
WHERE NOT EXISTS ( SELECT 1 FROM chill_person_marital_status WHERE name::jsonb = t.maritalstatus1 );
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- DOWN
|
-- DOWN
|
||||||
--
|
--
|
||||||
|
|
||||||
|
-- Undo 5.
|
||||||
|
DELETE FROM chill_person_marital_status cpms USING import.choix_personnes icp WHERE cpms.name::jsonb = icp.maritalstatus1::jsonb AND cpms.id <> 'célibat.' AND cpms.id <> 'marié'; -- existing marital status
|
||||||
|
ALTER TABLE import.choix_personnes DROP column maritalstatus1;
|
||||||
|
|
||||||
-- Undo 4.
|
-- Undo 4.
|
||||||
DELETE FROM country USING import.choix_personnes icp WHERE country.name::jsonb = icp.country1::jsonb AND country.id > 249; -- 249 existing countries
|
DELETE FROM country USING import.choix_personnes icp WHERE country.name::jsonb = icp.country1::jsonb AND country.id > 249; -- 249 existing countries
|
||||||
SELECT setval('country_id_seq', (SELECT max(id) FROM country));
|
SELECT setval('country_id_seq', (SELECT max(id) FROM country));
|
||||||
@ -71,7 +80,7 @@ ALTER TABLE import.periodes DROP column closingdate1;
|
|||||||
|
|
||||||
-- -------------
|
-- -------------
|
||||||
|
|
||||||
-- personnes choices_list: gender maritalstatus household_composition_type household_position
|
-- personnes choices_list: gender household_composition_type household_position
|
||||||
-- periodes choices_list: intensity referrer job acp_scopes acp_socialissues work_socialaction
|
-- periodes choices_list: intensity referrer job acp_scopes acp_socialissues work_socialaction
|
||||||
-- tiers choices_list: civility kind profession category
|
-- tiers choices_list: civility kind profession category
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user