Skip to content

Commit

Permalink
Revert "fix: embedded fs on windows (#537)"
Browse files Browse the repository at this point in the history
This reverts commit 716b623.
  • Loading branch information
amacneil committed Apr 21, 2024
1 parent 92fbde5 commit 4be528e
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions pkg/dbmate/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"io/fs"
"net/url"
"os"
"path"
"path/filepath"
"regexp"
"sort"
Expand Down Expand Up @@ -361,11 +360,7 @@ func (db *DB) Migrate() error {
}

if len(pendingMigrations) > 0 && db.Strict && pendingMigrations[0].Version <= highestAppliedMigrationVersion {
return fmt.Errorf(
"migration `%s` is out of order with already applied migrations, the version number has to be higher than the applied migration `%s` in --strict mode",
pendingMigrations[0].Version,
highestAppliedMigrationVersion,
)
return fmt.Errorf("migration `%s` is out of order with already applied migrations, the version number has to be higher than the applied migration `%s` in --strict mode", pendingMigrations[0].Version, highestAppliedMigrationVersion)
}

sqlDB, err := db.openDatabaseForMigration(drv)
Expand Down Expand Up @@ -428,7 +423,7 @@ func (db *DB) printVerbose(result sql.Result) {
}

func (db *DB) readMigrationsDir(dir string) ([]fs.DirEntry, error) {
path := path.Clean(dir)
path := filepath.Clean(dir)

// We use nil instead of os.DirFS() because DirFS cannot support both relative and absolute
// directory paths - it must be anchored at either "." or "/", which we do not know in advance.
Expand Down Expand Up @@ -488,7 +483,7 @@ func (db *DB) FindMigrations() ([]Migration, error) {
migration := Migration{
Applied: false,
FileName: matches[0],
FilePath: path.Join(dir, matches[0]),
FilePath: filepath.Join(dir, matches[0]),
FS: db.FS,
Version: matches[1],
}
Expand All @@ -500,11 +495,9 @@ func (db *DB) FindMigrations() ([]Migration, error) {
}
}

sort.Slice(
migrations, func(i, j int) bool {
return migrations[i].FileName < migrations[j].FileName
},
)
sort.Slice(migrations, func(i, j int) bool {
return migrations[i].FileName < migrations[j].FileName
})

return migrations, nil
}
Expand Down

0 comments on commit 4be528e

Please sign in to comment.