use validfrom in address insertion

This commit is contained in:
Mathieu Jaumotte 2023-03-10 12:55:53 +01:00
parent 1cc1b83435
commit dd3769e2a0

View File

@ -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;
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
address_id, postcode_id, street, streetnumber, extra, CURRENT_DATE
address_id, postcode_id, street, streetnumber, extra, COALESCE(validfrom1 , CURRENT_DATE)
FROM import.personnes WHERE postcode_id IS NOT NULL;
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;