A migration manager written in Golang. Use it in run commands via the CLI. This fork support cli without the needs of configuration file.
kamimai
is written in Go, so if you have Go installed you can install it with go get:
go get github.com/Fs02/kamimai/cmd/kamimai
Make sure that kamimai
was installed correctly:
kamimai -h
# create new migration files
kamimai --driver=mysql --dsn="mysql://user:password@(host:port)/database" --directory=./db/migrations create migrate_name
# apply all available migrations
kamimai --driver=mysql --dsn="mysql://user:password@(host:port)/database" --directory=./db/migrations up
# apply the next n migrations
kamimai --driver=mysql --dsn="mysql://user:password@(host:port)/database" --directory=./db/migrations up n
# apply the given version migration
kamimai --driver=mysql --dsn="mysql://user:password@(host:port)/database" --directory=./db/migrations up -version=20060102150405
# rollback the previous migration
kamimai --driver=mysql --dsn="mysql://user:password@(host:port)/database" --directory=./db/migrations down
# rollback the previous n migrations
kamimai --driver=mysql --dsn="mysql://user:password@(host:port)/database" --directory=./db/migrations down n
# rollback the given version migration
kamimai --driver=mysql --dsn="mysql://user:password@(host:port)/database" --directory=./db/migrations down -version=20060102150405
# sync all migrations
kamimai --driver=mysql --dsn="mysql://user:password@(host:port)/database" --directory=./db/migrations sync
package main
import (
"github.com/eure/kamimai"
"github.com/eure/kamimai/core"
_ "github.com/eure/kamimai/driver"
)
func main() {
conf, err := core.NewConfig("examples/testdata")
if err != nil {
panic(err)
}
conf.WithEnv("development")
// Sync
kamimai.Sync(conf)
// ...
- MySQL
- SQLite
- PostgreSQL
- and more