60. Link jobs to periods
This commit is contained in:
parent
12f0ec0ae4
commit
d9152fc090
@ -347,7 +347,7 @@ INSERT INTO chill_main_address (id, postcode_id, street, streetnumber, validFrom
|
||||
ALTER TABLE import.choix_periodes ADD COLUMN address_location_id BIGINT;
|
||||
UPDATE import.choix_periodes SET address_location_id = (SELECT max(id) FROM chill_main_address) WHERE street != '';
|
||||
|
||||
-- 54. Link period to person or temporary address location
|
||||
-- 54. Link person or temporary address location to periods
|
||||
UPDATE chill_person_accompanying_period acp
|
||||
SET addresslocation_id = (SELECT address_location_id FROM import.choix_periodes WHERE address_location_id IS NOT NULL LIMIT 1)
|
||||
FROM import.personnes pson JOIN import.periodes piod ON pson.id = piod.id
|
||||
@ -395,10 +395,15 @@ INSERT INTO accompanying_periods_scopes (accompanying_period_id, scope_id)
|
||||
|
||||
-- 59. Link origin to periods
|
||||
UPDATE chill_person_accompanying_period acp SET origin_id =
|
||||
(SELECT id FROM chill_person_accompanying_period_origin o WHERE o.label::jsonb->>'fr' = ip.origin1::jsonb->>'fr' )
|
||||
(SELECT id FROM chill_person_accompanying_period_origin o WHERE o.label::jsonb->>'fr' = ip.origin1::jsonb->>'fr')
|
||||
FROM import.periodes ip WHERE acp.id = ip.period_id;
|
||||
--SELECT ip.id, ip.origin1, acp.id as period_id, acp.origin_id FROM chill_person_accompanying_period acp JOIN import.periodes ip ON ip.period_id = acp.id ORDER BY ip.id;
|
||||
|
||||
-- 60. Link jobs to periods
|
||||
UPDATE chill_person_accompanying_period acp SET job_id =
|
||||
(SELECT id FROM chill_main_user_job j WHERE j.label::jsonb->>'fr' = ip.job1::jsonb->>'fr')
|
||||
FROM import.periodes ip WHERE acp.id = ip.period_id;
|
||||
|
||||
|
||||
-- ========================================================================================= --
|
||||
|
||||
@ -406,6 +411,9 @@ FROM import.periodes ip WHERE acp.id = ip.period_id;
|
||||
-- DOWN
|
||||
--
|
||||
|
||||
-- Undo 60.
|
||||
UPDATE chill_person_accompanying_period acp SET job_id = null FROM import.periodes ip WHERE acp.id = ip.period_id;
|
||||
|
||||
-- Undo 59.
|
||||
UPDATE chill_person_accompanying_period acp SET origin_id = null FROM import.periodes ip WHERE ip.period_id = acp.id;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user