diff --git a/internal/db/schema/internal/postgres/postgres.go b/internal/db/schema/internal/postgres/postgres.go index 7351981d31..afc4daeeaa 100644 --- a/internal/db/schema/internal/postgres/postgres.go +++ b/internal/db/schema/internal/postgres/postgres.go @@ -208,8 +208,11 @@ func (p *Postgres) RollbackRun(ctx context.Context) error { defer func() { p.tx = nil }() + + // p.tx is set to nil after the commit so if p.tx == nil, we assume that the transaction has + // already been committed and do nothing if p.tx == nil { - return errors.New(ctx, errors.MigrationIntegrity, op, "no pending transaction") + return nil } if err := p.tx.Rollback(); err != nil { if errors.Is(err, sql.ErrTxDone) { diff --git a/internal/db/schema/manager.go b/internal/db/schema/manager.go index 9f2426085a..000c8aca93 100644 --- a/internal/db/schema/manager.go +++ b/internal/db/schema/manager.go @@ -243,12 +243,9 @@ func (b *Manager) ApplyMigrations(ctx context.Context) ([]RepairLog, error) { // runMigrations passes migration queries to a database driver and manages // the version and dirty bit. Cancellation or deadline/timeout is managed // through the passed in context. -func (b *Manager) runMigrations(ctx context.Context, p *provider.Provider) ([]RepairLog, error) { +func (b *Manager) runMigrations(ctx context.Context, p *provider.Provider) (logEntries []RepairLog, retErr error) { const op = "schema.(Manager).runMigrations" - var logEntries []RepairLog - var retErr error - if startErr := b.driver.StartRun(ctx); startErr != nil { return nil, errors.Wrap(ctx, startErr, op) } @@ -312,5 +309,5 @@ func (b *Manager) runMigrations(ctx context.Context, p *provider.Provider) ([]Re return nil, errors.Wrap(ctx, err, op) } - return logEntries, retErr + return logEntries, nil }