diff --git a/userapi/storage/sqlite3/deltas/2022110411000000_server_names.go b/userapi/storage/sqlite3/deltas/2022110411000000_server_names.go index 5e05d5cad..3ba43b2e6 100644 --- a/userapi/storage/sqlite3/deltas/2022110411000000_server_names.go +++ b/userapi/storage/sqlite3/deltas/2022110411000000_server_names.go @@ -28,7 +28,7 @@ var serverNamesTables = []string{ func UpServerNames(ctx context.Context, tx *sql.Tx, serverName gomatrixserverlib.ServerName) error { for _, table := range serverNamesTables { q := fmt.Sprintf( - "SELECT name FROM sqlite_schema WHERE type='table' AND name=%s;", + "SELECT COUNT(name) FROM sqlite_schema WHERE type='table' AND name=%s;", pq.QuoteIdentifier(table), ) var c int diff --git a/userapi/storage/sqlite3/deltas/2022110411000001_server_names.go b/userapi/storage/sqlite3/deltas/2022110411000001_server_names.go index 36b3f30e3..04a47fa7b 100644 --- a/userapi/storage/sqlite3/deltas/2022110411000001_server_names.go +++ b/userapi/storage/sqlite3/deltas/2022110411000001_server_names.go @@ -17,14 +17,6 @@ import ( func UpServerNamesPopulate(ctx context.Context, tx *sql.Tx, serverName gomatrixserverlib.ServerName) error { for _, table := range serverNamesTables { q := fmt.Sprintf( - "SELECT name FROM sqlite_schema WHERE type='table' AND name=%s;", - pq.QuoteIdentifier(table), - ) - var c int - if err := tx.QueryRowContext(ctx, q).Scan(&c); err != nil || c == 0 { - continue - } - q = fmt.Sprintf( "UPDATE %s SET server_name = %s WHERE server_name = '';", pq.QuoteIdentifier(table), pq.QuoteLiteral(string(serverName)), )