diff --git a/migrate/migrate.go b/migrate/migrate.go index 130479b..b80e398 100644 --- a/migrate/migrate.go +++ b/migrate/migrate.go @@ -16,7 +16,7 @@ import ( "github.com/pkg/errors" ) -var migrationPattern = regexp.MustCompile(`\A(\d+)_.+\.sql\z`) +var migrationPattern = regexp.MustCompile(`\A(\d+)_[^\.]+\.sql\z`) var ErrNoFwMigration = errors.Errorf("no sql in forward migration step") @@ -127,7 +127,7 @@ func FindMigrationsEx(path string, fs MigratorFS) ([]string, error) { return nil, err } - mcount := len(paths) + 100 + mcount := len(paths) if n < int64(mcount) { return nil, fmt.Errorf("Duplicate migration %d", n) diff --git a/serv/cmd_migrate.go b/serv/cmd_migrate.go index 44283d9..7ba6b50 100644 --- a/serv/cmd_migrate.go +++ b/serv/cmd_migrate.go @@ -124,7 +124,7 @@ func cmdDBNew(cmd *cobra.Command, args []string) { os.Exit(1) } - mname := fmt.Sprintf("%03d_%s.sql", len(m)+100, name) + mname := fmt.Sprintf("%03d_%s.sql", (len(m) + 1), name) // Write new migration mpath := filepath.Join(conf.MigrationsPath, mname)