Skip to content

Commit

Permalink
fix: update total statements in the migration when it is being executed
Browse files Browse the repository at this point in the history
The reason for this is that users are required to edit existing migration files to resolve partial failure issues. Without keeping total in sync, such migration would be considered still pending, because total != applied.
Issue: ariga#2455
  • Loading branch information
ruslic19 committed Jan 17, 2024
1 parent d9bae09 commit ac666f9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sql/migrate/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,12 @@ func (e *Executor) Execute(ctx context.Context, m File) (err error) {
Hash: hash,
}
}

// Update total statements in the existing revision to support
// statement-level granularity in cases when users add new statements to
// existing migrations to resolve partial failures.
r.Total = len(stmts)

// Save once to mark as started in the database.
if err = e.writeRevision(ctx, r); err != nil {
return err
Expand Down

0 comments on commit ac666f9

Please sign in to comment.