sqlite: DB connection is not thread safe. Set max open connections to 1
Some checks failed
/ push (push) Has been cancelled

This commit is contained in:
Tigor Hutasuhut 2024-05-22 08:00:25 +07:00
parent f78661aa6e
commit 327c8380af

View file

@ -38,6 +38,9 @@ func Open(cfg *config.Config) (*sql.DB, error) {
if err != nil {
return db, errs.Wrapw(err, "failed to open database", "driver", driver, "db.string", dsn)
}
if driver == "sqlite3" {
db.SetMaxOpenConns(1) // SQLITE is not thread safe. This is to prevent database is locked error.
}
if cfg.Bool("db.automigrate") {
goose.SetLogger(goose.NopLogger())
goose.SetBaseFS(Migrations)