From dd208b6e82003235c68db13ee3e13995a3462abe Mon Sep 17 00:00:00 2001 From: Andrew Ferrazzutti Date: Thu, 11 Aug 2022 10:44:37 -0400 Subject: [PATCH] Exclude missing accounts from contact migration Otherwise, moveContacts fails with a foreign key constraint violation. --- cmd/signaldctl/cmd/db/migrate.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/signaldctl/cmd/db/migrate.go b/cmd/signaldctl/cmd/db/migrate.go index 122e499..86858e9 100644 --- a/cmd/signaldctl/cmd/db/migrate.go +++ b/cmd/signaldctl/cmd/db/migrate.go @@ -614,7 +614,9 @@ func moveGroupCredentials(source *sql.DB, dest *sql.DB) error { } func moveContacts(source *sql.DB, dest *sql.DB) error { - rows, err := source.Query("SELECT account_uuid, recipient, name, color, profile_key, message_expiration_time, inbox_position FROM contacts") + rows, err := source.Query("SELECT account_uuid, recipient, name, color, profile_key, message_expiration_time, inbox_position FROM contacts" + + " WHERE account_uuid IN (SELECT DISTINCT uuid FROM accounts)", + ) if err != nil { return err }