From dd3769e2a09bda39353ea9c2a3f8392207ce8fab Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Fri, 10 Mar 2023 12:55:53 +0100 Subject: [PATCH] use validfrom in address insertion --- sql/import.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/import.sql b/sql/import.sql index 0b67939..4bf3be6 100644 --- a/sql/import.sql +++ b/sql/import.sql @@ -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;