Fix bug with creating new migrations

This commit is contained in:
Vikram Rangnekar 2019-11-10 01:33:06 -05:00
parent 3438c3efb9
commit 06ed823a51
2 changed files with 3 additions and 3 deletions

View File

@ -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)

View File

@ -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)