Skip to content

Commit

Permalink
feat: allow empty migrations in providers
Browse files Browse the repository at this point in the history
  • Loading branch information
the-glu committed Feb 5, 2025
1 parent 7242b16 commit 51983ab
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,6 @@ func newProvider(
if err != nil {
return nil, err
}
if len(migrations) == 0 {
return nil, ErrNoMigrations
}
return &Provider{
db: db,
fsys: fsys,
Expand Down Expand Up @@ -505,7 +502,11 @@ func (p *Provider) getVersions(ctx context.Context) (current, target int64, retE
retErr = multierr.Append(retErr, cleanup())
}()

target = p.migrations[len(p.migrations)-1].Version
if len(p.migrations) > 0 {
target = p.migrations[len(p.migrations)-1].Version
} else {
target = 0 //If there are no migrations, the target is 0
}

// If versioning is disabled, we always have pending migrations and the target version is the
// last migration.
Expand Down

0 comments on commit 51983ab

Please sign in to comment.