From 091210dee5235c140432d01175ce6d997b01b98e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89mile=20R=C3=A9?= Date: Fri, 6 Feb 2026 17:27:19 +0400 Subject: [PATCH] Make sure nameless identities get a full_name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Émile Ré --- pkg/coredata/migrations/20260203T132700Z.sql | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/pkg/coredata/migrations/20260203T132700Z.sql b/pkg/coredata/migrations/20260203T132700Z.sql index 7b86c30c8..481cc9794 100644 --- a/pkg/coredata/migrations/20260203T132700Z.sql +++ b/pkg/coredata/migrations/20260203T132700Z.sql @@ -138,7 +138,7 @@ ADD SET NULL; --- 3. Create missing identities +-- 3. Create missing identities (one row per email to avoid "cannot affect row a second time") INSERT INTO identities ( id, @@ -156,7 +156,19 @@ SELECT FALSE, p.full_name 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 WITH people_identities AS ( @@ -562,4 +574,4 @@ FROM people_identities pi WHERE pi.organization_id = i.organization_id - AND i.email = pi.email_address; \ No newline at end of file + AND i.email = pi.email_address;