Exclude missing accounts from contact migration

Otherwise, moveContacts fails with a foreign key constraint violation.
This commit is contained in:
Andrew Ferrazzutti 2022-08-11 10:44:37 -04:00
parent 9928e5ffc2
commit dd208b6e82

View file

@ -614,7 +614,9 @@ func moveGroupCredentials(source *sql.DB, dest *sql.DB) error {
} }
func moveContacts(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 { if err != nil {
return err return err
} }