diff --git a/migrate.go b/migrate.go index edbced5..7994ef4 100644 --- a/migrate.go +++ b/migrate.go @@ -5,6 +5,7 @@ import ( "errors" "fmt" "log" + "os" "path/filepath" "runtime" "sort" @@ -105,6 +106,10 @@ func AddNamedMigration(filename string, up func(*sql.Tx) error, down func(*sql.T // CollectMigrations returns all the valid looking migration scripts in the // migrations folder and go func registry, and key them by version. func CollectMigrations(dirpath string, current, target int64) (Migrations, error) { + if _, err := os.Stat(dirpath); os.IsNotExist(err) { + return nil, fmt.Errorf("%s directory does not exists", dirpath) + } + var migrations Migrations // SQL migration files.