Improve date management for not specified dates
- use real import date for person createdat field - use year first day for not specified startdate, comment date, etc.
This commit is contained in:
parent
dd3769e2a0
commit
cadcddddb5
@ -267,10 +267,10 @@ INSERT INTO chill_person_person (
|
|||||||
, (SELECT c.id FROM chill_main_civility c WHERE c.name::jsonb->>'fr' = ip.civility1::jsonb->>'fr' AND ip.civility1 IS NOT NULL ) -- civility_id
|
, (SELECT c.id FROM chill_main_civility c WHERE c.name::jsonb->>'fr' = ip.civility1::jsonb->>'fr' AND ip.civility1 IS NOT NULL ) -- civility_id
|
||||||
, (SELECT ms.id FROM chill_person_marital_status ms WHERE ms.name::jsonb->>'fr' = ip.maritalstatus1::jsonb->>'fr' AND ip.maritalstatus1 IS NOT NULL ) -- maritalstatus_id,
|
, (SELECT ms.id FROM chill_person_marital_status ms WHERE ms.name::jsonb->>'fr' = ip.maritalstatus1::jsonb->>'fr' AND ip.maritalstatus1 IS NOT NULL ) -- maritalstatus_id,
|
||||||
, TRIM(firstname), UPPER(TRIM(lastname)), birthdate1, TRIM(place_of_birth), TRIM(memo), TRIM(email), TRIM(contactinfo), phonenumber1, mobilenumber1, numberofchildren1, gender1, deathdate1, false
|
, TRIM(firstname), UPPER(TRIM(lastname)), birthdate1, TRIM(place_of_birth), TRIM(memo), TRIM(email), TRIM(contactinfo), phonenumber1, mobilenumber1, numberofchildren1, gender1, deathdate1, false
|
||||||
, CURRENT_DATE, CURRENT_DATE -- createdat, updatedat
|
, CURRENT_DATE, CURRENT_DATE -- createdat, updatedat (= import date)
|
||||||
, (SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM users), (SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM users) -- createdby_id, updatedby_id
|
, (SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM users), (SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM users) -- createdby_id, updatedby_id
|
||||||
, (SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM centers) -- center_id
|
, (SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM centers) -- center_id
|
||||||
, TRIM(gendercomment), (SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM users), CURRENT_DATE
|
, TRIM(gendercomment), (SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM users), date(date_trunc('year', CURRENT_DATE)) --gendercomment_<comment|userid|date>
|
||||||
/*
|
/*
|
||||||
, -- maritalstatusdate
|
, -- maritalstatusdate
|
||||||
, -- maritalstatuscomment_comment, maritalstatuscomment_userid, maritalstatuscomment_date
|
, -- maritalstatuscomment_comment, maritalstatuscomment_userid, maritalstatuscomment_date
|
||||||
@ -282,7 +282,7 @@ FROM import.personnes ip;
|
|||||||
INSERT INTO chill_person_person_center_history (id, person_id, center_id, startdate) SELECT
|
INSERT INTO chill_person_person_center_history (id, person_id, center_id, startdate) SELECT
|
||||||
nextval('chill_person_person_center_history_id_seq'), person_id,
|
nextval('chill_person_person_center_history_id_seq'), person_id,
|
||||||
(SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM centers) , -- center_id
|
(SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM centers) , -- center_id
|
||||||
CURRENT_DATE
|
date(date_trunc('year', CURRENT_DATE))
|
||||||
FROM import.personnes ip;
|
FROM import.personnes ip;
|
||||||
-- SELECT ip.id, ip.lastname, ip.firstname, ip.person_id, hist.id, hist.person_id, hist.center_id, hist.startdate, p.id, p.fullnamecanonical, p.email FROM chill_person_person p RIGHT JOIN import.personnes ip ON ip.person_id = p.id FULL JOIN chill_person_person_center_history hist on p.id = hist.person_id ORDER BY ip.person_id;
|
-- SELECT ip.id, ip.lastname, ip.firstname, ip.person_id, hist.id, hist.person_id, hist.center_id, hist.startdate, p.id, p.fullnamecanonical, p.email FROM chill_person_person p RIGHT JOIN import.personnes ip ON ip.person_id = p.id FULL JOIN chill_person_person_center_history hist on p.id = hist.person_id ORDER BY ip.person_id;
|
||||||
|
|
||||||
@ -292,7 +292,7 @@ UPDATE import.personnes SET address_id = nextval('chill_main_address_id_seq');
|
|||||||
ALTER TABLE import.personnes ADD column postcode_id BIGINT;
|
ALTER TABLE import.personnes ADD column postcode_id BIGINT;
|
||||||
UPDATE import.personnes SET postcode_id = cmpc.id FROM chill_main_postal_code cmpc WHERE cmpc.code = postcode AND cmpc.origin = 0;
|
UPDATE import.personnes SET postcode_id = cmpc.id FROM chill_main_postal_code cmpc WHERE cmpc.code = postcode AND cmpc.origin = 0;
|
||||||
INSERT INTO chill_main_address (id, postcode_id, street, streetnumber, extra, validFrom) SELECT
|
INSERT INTO chill_main_address (id, postcode_id, street, streetnumber, extra, validFrom) SELECT
|
||||||
address_id, postcode_id, street, streetnumber, extra, COALESCE(validfrom1 , CURRENT_DATE)
|
address_id, postcode_id, street, streetnumber, extra, COALESCE(validfrom1 , date(date_trunc('year', CURRENT_DATE)))
|
||||||
FROM import.personnes WHERE postcode_id IS NOT NULL;
|
FROM import.personnes WHERE postcode_id IS NOT NULL;
|
||||||
SELECT ip.person_id, ip.address_id FROM import.personnes ip ;
|
SELECT ip.person_id, ip.address_id FROM import.personnes ip ;
|
||||||
-- SELECT ip.id, ip.person_id, ip.firstname, ip.lastname, addr.* FROM chill_main_address addr RIGHT JOIN import.personnes ip ON addr.id = ip.address_id ORDER BY ip.id;
|
-- SELECT ip.id, ip.person_id, ip.firstname, ip.lastname, addr.* FROM chill_main_address addr RIGHT JOIN import.personnes ip ON addr.id = ip.address_id ORDER BY ip.id;
|
||||||
@ -301,7 +301,7 @@ SELECT ip.person_id, ip.address_id FROM import.personnes ip ;
|
|||||||
INSERT INTO chill_person_household (id) SELECT person_id from import.personnes;
|
INSERT INTO chill_person_household (id) SELECT person_id from import.personnes;
|
||||||
SELECT setval('chill_person_household_id_seq', (SELECT max(id) FROM chill_person_household));
|
SELECT setval('chill_person_household_id_seq', (SELECT max(id) FROM chill_person_household));
|
||||||
INSERT INTO chill_person_household_members (id, person_id, household_id, startdate, sharedhousehold, position_id, holder) SELECT
|
INSERT INTO chill_person_household_members (id, person_id, household_id, startdate, sharedhousehold, position_id, holder) SELECT
|
||||||
nextval('chill_person_household_members_id_seq'), person_id, person_id, COALESCE(household_startdate1, CURRENT_DATE),
|
nextval('chill_person_household_members_id_seq'), person_id, person_id, COALESCE(household_startdate1, date(date_trunc('year', CURRENT_DATE))),
|
||||||
true, (SELECT id FROM chill_person_household_position pos WHERE household_position1::jsonb->>'fr' = pos.label::jsonb->>'fr'), false
|
true, (SELECT id FROM chill_person_household_position pos WHERE household_position1::jsonb->>'fr' = pos.label::jsonb->>'fr'), false
|
||||||
FROM import.personnes;
|
FROM import.personnes;
|
||||||
-- SELECT ip.id, ip.person_id, ip.firstname, ip.lastname, hh.* FROM chill_person_household hh FULL JOIN import.personnes ip ON hh.id = ip.person_id ORDER BY hh.id;
|
-- SELECT ip.id, ip.person_id, ip.firstname, ip.lastname, hh.* FROM chill_person_household hh FULL JOIN import.personnes ip ON hh.id = ip.person_id ORDER BY hh.id;
|
||||||
|
Loading…
Reference in New Issue
Block a user