Skip to content

Commit 7f44302

Browse files
Remove redundant check from UnappliedMigrations method (#869)
Remove the `latestVersion` check from the `UnappliedMigrations` method - used to calculate which migrations need to be applied by `pgroll migrate` The condition that stops the loop on lines 71 is sufficient. There is good test coverage of this behaviour (in `unapplied_test.go`) to support this check being unnecessary.
1 parent a7c4bb5 commit 7f44302

File tree

1 file changed

+0
-8
lines changed

1 file changed

+0
-8
lines changed

pkg/roll/unapplied.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ import (
1818
// If the local order of migrations does not match the order of migrations in
1919
// the schema history, an `ErrMismatchedMigration` error is returned.
2020
func (m *Roll) UnappliedMigrations(ctx context.Context, dir fs.FS) ([]*migrations.RawMigration, error) {
21-
latestVersion, err := m.State().LatestVersion(ctx, m.Schema())
22-
if err != nil {
23-
return nil, fmt.Errorf("determining latest version: %w", err)
24-
}
25-
2621
history, err := m.State().SchemaHistory(ctx, m.Schema())
2722
if err != nil {
2823
return nil, fmt.Errorf("reading schema history: %w", err)
@@ -84,9 +79,6 @@ func (m *Roll) UnappliedMigrations(ctx context.Context, dir fs.FS) ([]*migration
8479
}
8580

8681
appliedCount++
87-
if m.Name == *latestVersion {
88-
break
89-
}
9082
}
9183

9284
// Return only the migrations that haven't been applied yet

0 commit comments

Comments
 (0)