From 8bb40967e5858ee8c93debc65f56c3eb218fe83d Mon Sep 17 00:00:00 2001 From: finn Date: Wed, 2 Mar 2022 15:16:25 -0800 Subject: [PATCH] forget e164s that don't start with a + --- cmd/signaldctl/cmd/db/migrate.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmd/signaldctl/cmd/db/migrate.go b/cmd/signaldctl/cmd/db/migrate.go index 01e1d4a..0bb6c9b 100644 --- a/cmd/signaldctl/cmd/db/migrate.go +++ b/cmd/signaldctl/cmd/db/migrate.go @@ -7,6 +7,7 @@ import ( "log" "os" "os/user" + "strings" "time" "github.com/lib/pq" @@ -225,6 +226,13 @@ func moveRecipients(source *sql.DB, dest *sql.DB) error { if err != nil { return err } + + if e164.Valid && !strings.HasPrefix(e164.String, "+") { + log.Println("corrupt e164 found, setting to null") + e164.Valid = false + e164.String = "" + } + _, err = dest.Exec("INSERT INTO signald_recipients (rowid, account_uuid, uuid, e164) VALUES ($1, $2, $3, $4)", rowID, accountUUID, recipientUUID, e164) if err != nil { return err