Revert "remove route-runmigraions"

This reverts commit e3238c19c3.
This commit is contained in:
Cadey Ratio 2018-04-22 20:21:18 -07:00
parent c0bbcf68cb
commit 470fa49b6e
1 changed files with 43 additions and 0 deletions

View File

@ -0,0 +1,43 @@
package main
import (
"log"
"git.xeserv.us/xena/route/internal/database/dmigrations"
"github.com/caarlos0/env"
"github.com/mattes/migrate"
_ "github.com/mattes/migrate/database/postgres"
bindata "github.com/mattes/migrate/source/go-bindata"
)
type config struct {
DatabaseURL string `env:"DATABASE_URL,required"`
}
func main() {
var cfg config
err := env.Parse(&cfg)
if err != nil {
log.Fatal(err)
}
s := bindata.Resource(dmigrations.AssetNames(),
func(name string) ([]byte, error) {
return dmigrations.Asset(name)
})
d, err := bindata.WithInstance(s)
if err != nil {
log.Fatal(err)
}
m, err := migrate.NewWithSourceInstance("go-bindata", d, cfg.DatabaseURL)
if err != nil {
log.Fatal(err)
}
err = m.Up()
if err != nil {
log.Fatal(err)
}
}