Add a setval() query after INSERT INTO when id is not nextval()
This commit is contained in:
parent
67d020d322
commit
f513dd1b36
@ -272,6 +272,7 @@ INSERT INTO chill_person_person (
|
||||
, -- acceptsms, acceptemail
|
||||
*/
|
||||
FROM import.personnes ip;
|
||||
SELECT setval('chill_person_person_id_seq', (SELECT COALESCE(max(id)) FROM chill_person_person));
|
||||
|
||||
-- 42. Fill Person center history
|
||||
INSERT INTO chill_person_person_center_history (id, person_id, center_id, startdate) SELECT
|
||||
@ -289,6 +290,7 @@ UPDATE import.personnes SET postcode_id = pc.id FROM chill_main_postal_code pc W
|
||||
INSERT INTO chill_main_address (id, postcode_id, street, streetnumber, extra, validFrom) SELECT
|
||||
address_id, postcode_id, street, streetnumber, extra, COALESCE(validfrom1 , date(date_trunc('year', CURRENT_DATE)))
|
||||
FROM import.personnes WHERE postcode_id IS NOT NULL;
|
||||
SELECT setval('chill_main_address_id_seq', (SELECT COALESCE(max(id)) FROM chill_main_address));
|
||||
-- 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;
|
||||
|
||||
@ -302,7 +304,7 @@ INSERT INTO chill_person_household_members (id, person_id, household_id, startda
|
||||
-- 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, memb.* FROM chill_person_household_members memb JOIN import.personnes ip ON memb.household_id = ip.person_id ORDER BY memb.household_id;
|
||||
|
||||
-- 45. Add address to household
|
||||
-- 45. Link address to household
|
||||
INSERT INTO chill_person_household_to_addresses (household_id, address_id) SELECT person_id, address_id
|
||||
FROM import.personnes WHERE postcode_id IS NOT NULL; -- cfr (*) adresse insérées seulement si postcode
|
||||
|
||||
@ -326,6 +328,7 @@ INSERT INTO chill_person_accompanying_period (id, openingdate, step, remark, int
|
||||
(SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM users), CURRENT_DATE,
|
||||
(SELECT distinct(first_value(id) OVER(ORDER BY id)) FROM users), CURRENT_DATE
|
||||
FROM import.periodes;
|
||||
SELECT setval('chill_person_accompanying_period_id_seq', (SELECT max(id) FROM chill_person_accompanying_period));
|
||||
|
||||
-- ========================================================================================= --
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user