Fix bug with creating new migrations
This commit is contained in:
parent
3438c3efb9
commit
06ed823a51
|
@ -16,7 +16,7 @@ import (
|
||||||
"github.com/pkg/errors"
|
"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")
|
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
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
mcount := len(paths) + 100
|
mcount := len(paths)
|
||||||
|
|
||||||
if n < int64(mcount) {
|
if n < int64(mcount) {
|
||||||
return nil, fmt.Errorf("Duplicate migration %d", n)
|
return nil, fmt.Errorf("Duplicate migration %d", n)
|
||||||
|
|
|
@ -124,7 +124,7 @@ func cmdDBNew(cmd *cobra.Command, args []string) {
|
||||||
os.Exit(1)
|
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
|
// Write new migration
|
||||||
mpath := filepath.Join(conf.MigrationsPath, mname)
|
mpath := filepath.Join(conf.MigrationsPath, mname)
|
||||||
|
|
Loading…
Reference in New Issue