mirror of
https://github.com/getAlby/hub.git
synced 2026-08-13 12:33:39 +02:00
* fix: sqlite pragma statement not applying to all sqlite connections * fix: add migration to delete orphaned records * fix: migrate postgres transaction amount column to bigint * chore: simplify migration, update comment * fix: sqlite uri when running tests * fix: check that breaks tests * fix: db locking within transaction * fix: sqlite3 driver wrapper to execute PRAGMAs on each new connection (#1464) * fix: sqlite3 driver wrapper to execute PRAGMAs on each new connection * chore: add test to check temp_store value --------- Co-authored-by: Roland Bewick <roland.bewick@gmail.com> --------- Co-authored-by: Roman D <roman@dmitrienko.com>
22 lines
633 B
Go
22 lines
633 B
Go
package sqlite_wrapper
|
|
|
|
import (
|
|
"database/sql"
|
|
|
|
"github.com/mattn/go-sqlite3"
|
|
)
|
|
|
|
const Sqlite3WrapperDriverName = "sqlite3_wrapper"
|
|
|
|
func init() {
|
|
// We need to set the temp_store setting on every connection, including
|
|
// those that are implicitly opened by Go's database/sql package.
|
|
// Unfortunately, this setting cannot be provided in the DSN; therefore
|
|
// we execute the PRAGMA statement in the sqlite3's connection hook.
|
|
sql.Register(Sqlite3WrapperDriverName, &sqlite3.SQLiteDriver{
|
|
ConnectHook: func(conn *sqlite3.SQLiteConn) error {
|
|
_, err := conn.Exec("PRAGMA temp_store = MEMORY", nil)
|
|
return err
|
|
},
|
|
})
|
|
}
|