allow use of big version numbers

This commit is contained in:
goenning 2017-01-18 22:19:02 +00:00
parent de494e4b98
commit f1738e78db
2 changed files with 37 additions and 1 deletions

View File

@ -51,7 +51,7 @@ func (driver *Driver) ensureVersionTableExists() error {
if c > 0 {
return nil
}
if _, err := driver.db.Exec("CREATE TABLE IF NOT EXISTS " + tableName + " (version int not null primary key);"); err != nil {
if _, err := driver.db.Exec("CREATE TABLE IF NOT EXISTS " + tableName + " (version bigint not null primary key);"); err != nil {
return err
}
return nil

View File

@ -77,6 +77,28 @@ func TestMigrate(t *testing.T) {
)
`),
},
{
Path: "/foobar",
FileName: "20170118205923_demo.up.sql",
Version: 20170118205923,
Name: "demo",
Direction: direction.Up,
Content: []byte(`
CREATE TABLE demo (
id serial not null primary key
)
`),
},
{
Path: "/foobar",
FileName: "20170118205923_demo.down.sql",
Version: 20170118205923,
Name: "demo",
Direction: direction.Down,
Content: []byte(`
DROP TABLE demo
`),
},
}
pipe := pipep.New()
@ -100,6 +122,20 @@ func TestMigrate(t *testing.T) {
t.Error("Expected test case to fail")
}
pipe = pipep.New()
go d.Migrate(files[3], pipe)
errs = pipep.ReadErrors(pipe)
if len(errs) > 0 {
t.Fatal(errs)
}
pipe = pipep.New()
go d.Migrate(files[4], pipe)
errs = pipep.ReadErrors(pipe)
if len(errs) > 0 {
t.Fatal(errs)
}
if err := d.Close(); err != nil {
t.Fatal(err)
}