Skip to content

Commit

Permalink
chore: update pragma commands, add busy_timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
rolznz committed Jul 15, 2024
1 parent c018426 commit 1ed6961
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,19 @@ func NewDB(uri string) (*gorm.DB, error) {
if err != nil {
return nil, err
}
err = gormDB.Exec("PRAGMA foreign_keys=ON;").Error
err = gormDB.Exec("PRAGMA foreign_keys = ON", nil).Error
if err != nil {
return nil, err
}
err = gormDB.Exec("PRAGMA auto_vacuum=FULL;").Error
err = gormDB.Exec("PRAGMA auto_vacuum = FULL", nil).Error
if err != nil {
return nil, err
}

// sqlDb, err = DB.DB()
// if err != nil {
// return err
// }
// this causes errors when concurrently saving DB entries and otherwise requires mutexes
// sqlDb.SetMaxOpenConns(1)
err = gormDB.Exec("PRAGMA busy_timeout = 5000", nil).Error
if err != nil {
return nil, err
}

err = migrations.Migrate(gormDB)
if err != nil {
Expand Down

0 comments on commit 1ed6961

Please sign in to comment.