57. Link referrer to periods

This commit is contained in:
Mathieu Jaumotte 2023-03-11 13:39:42 +01:00
parent 1adf47e63e
commit 7893eb3c81

View File

@ -379,8 +379,12 @@ FROM (
JOIN import.choix_periodes icp ON p.acp_socialissues = icp.acp_socialissues JOIN import.choix_periodes icp ON p.acp_socialissues = icp.acp_socialissues
ORDER BY id) AS t; ORDER BY id) AS t;
-- 57. Link referrer to periods
UPDATE chill_person_accompanying_period acp
SET user_id = (SELECT id FROM users WHERE users.username = ip.referrer)
FROM import.periodes ip WHERE acp.id = ip.period_id;
--SELECT ip.id, (SELECT id FROM users WHERE users.username = ip.referrer) AS referrer_id, ip.referrer, acp.id as period_id, acp.user_id FROM chill_person_accompanying_period acp JOIN import.periodes ip ON ip.period_id = acp.id ORDER BY ip.id;
-- 57.
-- 58. -- 58.
-- 59. -- 59.
@ -393,6 +397,7 @@ FROM (
-- Undo 59. -- Undo 59.
-- Undo 58. -- Undo 58.
-- Undo 57. -- Undo 57.
UPDATE chill_person_accompanying_period acp SET user_id = null FROM import.periodes ip WHERE ip.period_id = acp.id;
-- Undo 56. -- Undo 56.
DELETE FROM chill_person_accompanying_period_social_issues asi USING import.periodes ip WHERE asi.accompanyingperiod_id = ip.period_id; DELETE FROM chill_person_accompanying_period_social_issues asi USING import.periodes ip WHERE asi.accompanyingperiod_id = ip.period_id;