From d69df41ef0c4b5c8cfa3b84b733d92bdaf46168d Mon Sep 17 00:00:00 2001 From: TwinProduction Date: Sat, 11 Sep 2021 22:42:56 -0400 Subject: [PATCH] Ensure connection to database by pinging it once before creating the schema --- storage/store/sql/sql.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/storage/store/sql/sql.go b/storage/store/sql/sql.go index 0d2a68b9..4b40e1f6 100644 --- a/storage/store/sql/sql.go +++ b/storage/store/sql/sql.go @@ -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")