aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorTill <2353100+S7evinK@users.noreply.github.com>2023-07-07 13:09:39 +0200
committerGitHub <noreply@github.com>2023-07-07 13:09:39 +0200
commitc08c7405dbe9d88c1364f6f1f2466db5045506cc (patch)
tree8652f76b9d38d1939ef405505cdb4ec5d68ad817 /internal
parentcc9b695c1ed22e47b723032793d4cf087c0f3ecc (diff)
Prepare statement on an existing transaction (#3144)
This should fix an issue with the database being locked for SQLite.
Diffstat (limited to 'internal')
-rw-r--r--internal/sqlutil/migrate.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/internal/sqlutil/migrate.go b/internal/sqlutil/migrate.go
index a66a7582..735fb492 100644
--- a/internal/sqlutil/migrate.go
+++ b/internal/sqlutil/migrate.go
@@ -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)
}