Ensure connection to database by pinging it once before creating the schema

This commit is contained in:
TwinProduction 2021-09-11 22:42:56 -04:00
parent cbfdc359d3
commit d69df41ef0

View File

@ -63,6 +63,9 @@ func NewStore(driver, path string) (*Store, error) {
if store.db, err = sql.Open(driver, path); err != nil {
return nil, err
}
if err := store.db.Ping(); err != nil {
return nil, err
}
if driver == "sqlite" {
_, _ = store.db.Exec("PRAGMA foreign_keys=ON")
_, _ = store.db.Exec("PRAGMA journal_mode=WAL")