6. complete chill_person_household_composition_type table
This commit is contained in:
parent
27ef1034be
commit
de8450267d
@ -50,37 +50,50 @@ INSERT INTO chill_person_marital_status (id, name)
|
|||||||
FROM ( SELECT DISTINCT ON (maritalstatus) maritalstatus1 FROM import.choix_personnes WHERE maritalstatus1 IS NOT NULL ) t
|
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 );
|
WHERE NOT EXISTS ( SELECT 1 FROM chill_person_marital_status WHERE name::jsonb = t.maritalstatus1 );
|
||||||
|
|
||||||
|
-- 6. Complete table household_composition_type
|
||||||
|
ALTER TABLE import.choix_personnes ADD COLUMN household_composition_type1 JSONB;
|
||||||
|
UPDATE import.choix_personnes SET household_composition_type1=json_build_object('fr', trim(household_composition_type)) WHERE household_composition_type!='';
|
||||||
|
INSERT INTO chill_person_household_composition_type (id, active, label)
|
||||||
|
SELECT nextval('chill_person_household_composition_type_id_seq'), true, t.household_composition_type1
|
||||||
|
FROM ( SELECT DISTINCT ON (household_composition_type) household_composition_type1 FROM import.choix_personnes WHERE household_composition_type1 IS NOT NULL ) t
|
||||||
|
WHERE NOT EXISTS ( SELECT 1 FROM chill_person_household_composition_type WHERE label::jsonb = t.household_composition_type1 );
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- DOWN
|
-- DOWN
|
||||||
--
|
--
|
||||||
|
|
||||||
|
-- Undo 6.
|
||||||
|
DELETE FROM chill_person_household_composition_type cphct USING import.choix_personnes icp WHERE cphct.label::jsonb = icp.household_composition_type1::jsonb AND cphct.id > 6;
|
||||||
|
SELECT setval('chill_person_household_composition_type_id_seq', (SELECT max(id) FROM chill_person_household_composition_type));
|
||||||
|
ALTER TABLE import.choix_personnes DROP COLUMN household_composition_type1;
|
||||||
|
|
||||||
-- Undo 5.
|
-- 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
|
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;
|
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));
|
||||||
ALTER TABLE import.choix_personnes DROP column country1;
|
ALTER TABLE import.choix_personnes DROP COLUMN country1;
|
||||||
|
|
||||||
-- Undo 3.
|
-- Undo 3.
|
||||||
DELETE FROM chill_main_civility cmc USING import.choix_personnes ip WHERE cmc.name::jsonb = ip.civility1::jsonb;
|
DELETE FROM chill_main_civility cmc USING import.choix_personnes ip WHERE cmc.name::jsonb = ip.civility1::jsonb;
|
||||||
SELECT setval('chill_main_civility_id_seq', (SELECT max(id) FROM chill_main_civility));
|
SELECT setval('chill_main_civility_id_seq', (SELECT max(id) FROM chill_main_civility));
|
||||||
ALTER TABLE import.choix_personnes DROP column civility1;
|
ALTER TABLE import.choix_personnes DROP COLUMN civility1;
|
||||||
|
|
||||||
-- Undo 2.
|
-- Undo 2.
|
||||||
ALTER TABLE import.personnes DROP column birthdate1;
|
ALTER TABLE import.personnes DROP COLUMN birthdate1;
|
||||||
ALTER TABLE import.personnes DROP column deathdate1;
|
ALTER TABLE import.personnes DROP COLUMN deathdate1;
|
||||||
ALTER TABLE import.personnes DROP column validfrom1;
|
ALTER TABLE import.personnes DROP COLUMN validfrom1;
|
||||||
ALTER TABLE import.personnes DROP column household_startdate1;
|
ALTER TABLE import.personnes DROP COLUMN household_startdate1;
|
||||||
ALTER TABLE import.periodes DROP column openingdate1;
|
ALTER TABLE import.periodes DROP COLUMN openingdate1;
|
||||||
ALTER TABLE import.periodes DROP column closingdate1;
|
ALTER TABLE import.periodes DROP COLUMN closingdate1;
|
||||||
|
|
||||||
|
|
||||||
-- -------------
|
-- -------------
|
||||||
|
|
||||||
-- personnes choices_list: gender household_composition_type household_position
|
-- personnes choices_list: gender 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
|
||||||
|
|
||||||
@ -89,4 +102,3 @@ ALTER TABLE import.periodes DROP column closingdate1;
|
|||||||
--
|
--
|
||||||
SELECT DISTINCT civility FROM import.personnes;
|
SELECT DISTINCT civility FROM import.personnes;
|
||||||
SELECT * FROM import.periodes;
|
SELECT * FROM import.periodes;
|
||||||
SELECT DISTINCT ON (civility) civility1 FROM import.personnes WHERE civility1 IS NOT NULL;
|
|
||||||
|
Loading…
Reference in New Issue
Block a user