Make sure nameless identities get a full_name
Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
@@ -138,7 +138,7 @@ ADD
|
|||||||
SET
|
SET
|
||||||
NULL;
|
NULL;
|
||||||
|
|
||||||
-- 3. Create missing identities
|
-- 3. Create missing identities (one row per email to avoid "cannot affect row a second time")
|
||||||
INSERT INTO
|
INSERT INTO
|
||||||
identities (
|
identities (
|
||||||
id,
|
id,
|
||||||
@@ -156,7 +156,19 @@ SELECT
|
|||||||
FALSE,
|
FALSE,
|
||||||
p.full_name
|
p.full_name
|
||||||
FROM
|
FROM
|
||||||
peoples p ON CONFLICT DO NOTHING;
|
(
|
||||||
|
SELECT DISTINCT ON (primary_email_address)
|
||||||
|
primary_email_address,
|
||||||
|
full_name
|
||||||
|
FROM
|
||||||
|
peoples
|
||||||
|
ORDER BY
|
||||||
|
primary_email_address
|
||||||
|
) p
|
||||||
|
ON CONFLICT (email_address) DO
|
||||||
|
UPDATE
|
||||||
|
SET
|
||||||
|
full_name = EXCLUDED.full_name;
|
||||||
|
|
||||||
-- 4. Create missing memberships
|
-- 4. Create missing memberships
|
||||||
WITH people_identities AS (
|
WITH people_identities AS (
|
||||||
@@ -562,4 +574,4 @@ FROM
|
|||||||
people_identities pi
|
people_identities pi
|
||||||
WHERE
|
WHERE
|
||||||
pi.organization_id = i.organization_id
|
pi.organization_id = i.organization_id
|
||||||
AND i.email = pi.email_address;
|
AND i.email = pi.email_address;
|
||||||
|
|||||||
Reference in New Issue
Block a user