mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-09 22:42:58 +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
@ -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 {
|
||||
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 {
|
||||
return fmt.Errorf("unable to prepare insert statement: %w", err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user