46. Add household composition
This commit is contained in:
parent
081ce76085
commit
307cfcbe74
@ -307,7 +307,11 @@ INSERT INTO chill_person_household_to_addresses (household_id, address_id) SELEC
|
|||||||
FROM import.personnes WHERE postcode_id IS NOT NULL; -- cfr (*) adresse insérées seulement si postcode
|
FROM import.personnes WHERE postcode_id IS NOT NULL; -- cfr (*) adresse insérées seulement si postcode
|
||||||
|
|
||||||
-- 46. Add household composition
|
-- 46. Add household composition
|
||||||
-- (not yet implemented in canvas)
|
INSERT INTO chill_person_household_composition (id, household_id, startdate, householdcompositiontype_id) SELECT
|
||||||
|
nextval('chill_person_household_composition_id_seq'), person_id AS household_id, date(date_trunc('year', CURRENT_DATE))
|
||||||
|
, (SELECT id FROM chill_person_household_composition_type ct WHERE household_composition_type1::jsonb->>'fr' = ct.label::jsonb->>'fr')
|
||||||
|
FROM import.personnes
|
||||||
|
WHERE household_composition_type1 IS NOT NULL ;
|
||||||
|
|
||||||
|
|
||||||
-- ========================================================================================= --
|
-- ========================================================================================= --
|
||||||
@ -316,6 +320,10 @@ INSERT INTO chill_person_household_to_addresses (household_id, address_id) SELEC
|
|||||||
-- DOWN
|
-- DOWN
|
||||||
--
|
--
|
||||||
|
|
||||||
|
-- Undo 46.
|
||||||
|
DELETE FROM chill_person_household_composition c USING import.personnes ip WHERE c.household_id = ip.person_id;
|
||||||
|
SELECT setval('chill_person_household_composition_id_seq', (SELECT max(id) FROM chill_person_household_composition));
|
||||||
|
|
||||||
-- Undo 45.
|
-- Undo 45.
|
||||||
DELETE FROM chill_person_household_to_addresses hhaddr USING import.personnes ip WHERE hhaddr.household_id = ip.person_id ;
|
DELETE FROM chill_person_household_to_addresses hhaddr USING import.personnes ip WHERE hhaddr.household_id = ip.person_id ;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user