mirror of
https://github.com/status-im/migrate.git
synced 2025-02-22 07:58:05 +00:00
Support date-based versions
This commit is contained in:
parent
b83285bd59
commit
d789d50bd6
@ -24,7 +24,7 @@ var Regex = regexp.MustCompile(`^([0-9]+)_(.*)\.(` + string(Down) + `|` + string
|
|||||||
func Parse(raw string) (*Migration, error) {
|
func Parse(raw string) (*Migration, error) {
|
||||||
m := Regex.FindStringSubmatch(raw)
|
m := Regex.FindStringSubmatch(raw)
|
||||||
if len(m) == 5 {
|
if len(m) == 5 {
|
||||||
versionUint64, err := strconv.ParseUint(m[1], 10, 32)
|
versionUint64, err := strconv.ParseUint(m[1], 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,16 @@ func TestParse(t *testing.T) {
|
|||||||
Raw: "1485385885_foobar.up.sql",
|
Raw: "1485385885_foobar.up.sql",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "20170412214116_date_foobar.up.sql",
|
||||||
|
expectErr: nil,
|
||||||
|
expectMigration: &Migration{
|
||||||
|
Version: 20170412214116,
|
||||||
|
Identifier: "date_foobar",
|
||||||
|
Direction: Up,
|
||||||
|
Raw: "20170412214116_date_foobar.up.sql",
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "-1_foobar.up.sql",
|
name: "-1_foobar.up.sql",
|
||||||
expectErr: ErrParse,
|
expectErr: ErrParse,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user