4. complete country table
This commit is contained in:
parent
9cd1f19f89
commit
40ebabf3f6
@ -34,7 +34,13 @@ INSERT INTO chill_main_civility (id, name, abbreviation, active, ordering)
|
||||
CROSS JOIN max_ordering
|
||||
WHERE NOT EXISTS ( SELECT 1 FROM chill_main_civility WHERE name::jsonb = t.civility1 );
|
||||
|
||||
|
||||
-- 4. Complete table Country
|
||||
ALTER TABLE import.choix_personnes ADD COLUMN country1 JSONB;
|
||||
UPDATE import.choix_personnes SET country1=json_build_object('fr', trim(country)) WHERE country!='';
|
||||
INSERT INTO country (id, name, countrycode)
|
||||
SELECT nextval('country_id_seq'), t.country1, 'ZZZ'
|
||||
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 );
|
||||
|
||||
|
||||
|
||||
@ -44,6 +50,11 @@ INSERT INTO chill_main_civility (id, name, abbreviation, active, ordering)
|
||||
-- DOWN
|
||||
--
|
||||
|
||||
-- Undo 4.
|
||||
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));
|
||||
ALTER TABLE import.choix_personnes DROP column country1;
|
||||
|
||||
-- Undo 3.
|
||||
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));
|
||||
@ -60,9 +71,9 @@ ALTER TABLE import.periodes DROP column closingdate1;
|
||||
|
||||
-- -------------
|
||||
|
||||
-- personnes choices_list: civility gender nationality countryofbirth country maritalstatus household_composition_type household_position
|
||||
-- personnes choices_list: gender maritalstatus household_composition_type household_position
|
||||
-- periodes choices_list: intensity referrer job acp_scopes acp_socialissues work_socialaction
|
||||
-- tiers choices_list: civility kind profession category country
|
||||
-- tiers choices_list: civility kind profession category
|
||||
|
||||
--
|
||||
-- SELECT
|
||||
|
Loading…
Reference in New Issue
Block a user