From bc7fe3d34f67b0aafbc995d4b4e5fa0202b6415c Mon Sep 17 00:00:00 2001 From: Martin Gysel Date: Thu, 15 Apr 2021 10:04:07 +0200 Subject: [PATCH] DiscoverSQLMigrationsFromFilesystem: assume underlaying fs use '/' as separator when DiscoverSQLMigrations() is called, a 'os nativ' fs is assumed, so convert the path to slash. when opening a file on such a fs, convert to back from slash to native separator. go-pg/migrations#107 --- collection.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/collection.go b/collection.go index 29c8d99..51b93e4 100644 --- a/collection.go +++ b/collection.go @@ -149,7 +149,7 @@ func (c *Collection) DiscoverSQLMigrations(dir string) error { return err } - return c.DiscoverSQLMigrationsFromFilesystem(osfilesystem{}, dir) + return c.DiscoverSQLMigrationsFromFilesystem(osfilesystem{}, filepath.ToSlash(dir)) } // DiscoverSQLMigrations scan the dir from the given filesystem for files with .sql extension @@ -219,7 +219,7 @@ func (c *Collection) DiscoverSQLMigrationsFromFilesystem(fs http.FileSystem, dir } m := newMigration(version) - filePath := filepath.Join(dir, fileName) + filePath := path.Join(dir, fileName) if strings.HasSuffix(fileName, ".up.sql") { if m.Up != nil { @@ -777,5 +777,5 @@ func init() { type osfilesystem struct{} func (osfilesystem) Open(name string) (http.File, error) { - return os.Open(name) + return os.Open(filepath.FromSlash(name)) }