From 7893eb3c81a4071e9dcb950760aa840eba704cb1 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Sat, 11 Mar 2023 13:39:42 +0100 Subject: [PATCH] 57. Link referrer to periods --- sql/import.sql | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sql/import.sql b/sql/import.sql index 66aaef8..ddca6e3 100644 --- a/sql/import.sql +++ b/sql/import.sql @@ -379,8 +379,12 @@ FROM ( JOIN import.choix_periodes icp ON p.acp_socialissues = icp.acp_socialissues 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. -- 59. @@ -393,6 +397,7 @@ FROM ( -- Undo 59. -- Undo 58. -- Undo 57. +UPDATE chill_person_accompanying_period acp SET user_id = null FROM import.periodes ip WHERE ip.period_id = acp.id; -- Undo 56. DELETE FROM chill_person_accompanying_period_social_issues asi USING import.periodes ip WHERE asi.accompanyingperiod_id = ip.period_id;