mirror of
https://github.com/tulir/mautrix-whatsapp
synced 2024-12-15 01:43:49 +01:00
Don't ignore errors when getting DB schema version
It probably never errors because connection errors would break the create table call, but this way is safer.
This commit is contained in:
parent
7f636e6aef
commit
ccfd7819c3
1 changed files with 4 additions and 3 deletions
|
@ -2,6 +2,7 @@ package upgrades
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -52,9 +53,9 @@ func GetVersion(db *sql.DB) (int, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
version := 0
|
version := 0
|
||||||
row := db.QueryRow("SELECT version FROM version LIMIT 1")
|
err = db.QueryRow("SELECT version FROM version LIMIT 1").Scan(&version)
|
||||||
if row != nil {
|
if err != nil && !errors.Is(err, sql.ErrNoRows) {
|
||||||
_ = row.Scan(&version)
|
return -1, err
|
||||||
}
|
}
|
||||||
return version, nil
|
return version, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue