mirror of
https://github.com/hoernschen/dendrite.git
synced 2024-12-27 07:28:27 +00:00
Prepare statement on an existing transaction (#3144)
This should fix an issue with the database being locked for SQLite.
This commit is contained in:
parent
cc9b695c1e
commit
c08c7405db
1 changed files with 7 additions and 1 deletions
|
@ -112,7 +112,13 @@ func (m *Migrator) Up(ctx context.Context) error {
|
||||||
|
|
||||||
func (m *Migrator) insertMigration(ctx context.Context, txn *sql.Tx, migrationName string) error {
|
func (m *Migrator) insertMigration(ctx context.Context, txn *sql.Tx, migrationName string) error {
|
||||||
if m.insertStmt == nil {
|
if m.insertStmt == nil {
|
||||||
stmt, err := m.db.Prepare(insertVersionSQL)
|
var stmt *sql.Stmt
|
||||||
|
var err error
|
||||||
|
if txn == nil {
|
||||||
|
stmt, err = m.db.PrepareContext(ctx, insertVersionSQL)
|
||||||
|
} else {
|
||||||
|
stmt, err = txn.PrepareContext(ctx, insertVersionSQL)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to prepare insert statement: %w", err)
|
return fmt.Errorf("unable to prepare insert statement: %w", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue