default value for socialissue_id, user_id, scope_id
This commit is contained in:
parent
d9152fc090
commit
07df6c4292
@ -369,7 +369,11 @@ INSERT INTO chill_person_accompanying_period_location_history (id, period_id, st
|
|||||||
INSERT INTO chill_person_accompanying_period_social_issues (accompanyingperiod_id, socialissue_id)
|
INSERT INTO chill_person_accompanying_period_social_issues (accompanyingperiod_id, socialissue_id)
|
||||||
SELECT
|
SELECT
|
||||||
DISTINCT ON (t.period_id) t.period_id,
|
DISTINCT ON (t.period_id) t.period_id,
|
||||||
COALESCE(t.enfant_id, t.parent_id, 1) AS socialissue_id -- quid si pas de socialissue ?
|
COALESCE(
|
||||||
|
t.enfant_id,
|
||||||
|
t.parent_id,
|
||||||
|
1 -- default value ?
|
||||||
|
) AS socialissue_id
|
||||||
FROM (
|
FROM (
|
||||||
SELECT p.period_id,
|
SELECT p.period_id,
|
||||||
(SELECT id FROM chill_person_social_issue WHERE title::jsonb->>'fr' = icp.parent1::jsonb->>'fr' AND parent_id IS NULL) AS parent_id, icp.parent1,
|
(SELECT id FROM chill_person_social_issue WHERE title::jsonb->>'fr' = icp.parent1::jsonb->>'fr' AND parent_id IS NULL) AS parent_id, icp.parent1,
|
||||||
@ -381,7 +385,10 @@ FROM (
|
|||||||
|
|
||||||
-- 57. Link referrer to periods
|
-- 57. Link referrer to periods
|
||||||
UPDATE chill_person_accompanying_period acp
|
UPDATE chill_person_accompanying_period acp
|
||||||
SET user_id = (SELECT id FROM users WHERE users.username = ip.referrer)
|
SET user_id = COALESCE(
|
||||||
|
(SELECT id FROM users WHERE users.username = ip.referrer),
|
||||||
|
1 -- default value ?
|
||||||
|
)
|
||||||
FROM import.periodes ip WHERE acp.id = ip.period_id;
|
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;
|
--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;
|
||||||
|
|
||||||
@ -389,7 +396,7 @@ UPDATE chill_person_accompanying_period acp
|
|||||||
INSERT INTO accompanying_periods_scopes (accompanying_period_id, scope_id)
|
INSERT INTO accompanying_periods_scopes (accompanying_period_id, scope_id)
|
||||||
SELECT ip.period_id, COALESCE(
|
SELECT ip.period_id, COALESCE(
|
||||||
(SELECT id FROM scopes s WHERE ip.acp_scopes1::jsonb->>'fr' = s.name::jsonb->>'fr'),
|
(SELECT id FROM scopes s WHERE ip.acp_scopes1::jsonb->>'fr' = s.name::jsonb->>'fr'),
|
||||||
(SELECT id from scopes s WHERE s.name::jsonb->>'fr' = 'tous') -- default 'tous'
|
(SELECT id from scopes s WHERE s.name::jsonb->>'fr' = 'tous') -- default value 'tous'
|
||||||
)
|
)
|
||||||
FROM import.periodes ip;
|
FROM import.periodes ip;
|
||||||
|
|
||||||
@ -599,8 +606,6 @@ ALTER TABLE import.periodes DROP COLUMN openingdate1;
|
|||||||
ALTER TABLE import.periodes DROP COLUMN closingdate1;
|
ALTER TABLE import.periodes DROP COLUMN closingdate1;
|
||||||
|
|
||||||
|
|
||||||
-- -------------
|
|
||||||
-- tiers choices_list: civility kind profession category
|
|
||||||
|
|
||||||
-- =============
|
-- =============
|
||||||
-- QUESTIONS
|
-- QUESTIONS
|
||||||
|
Loading…
Reference in New Issue
Block a user