A migration manager written in Golang. Use it in run commands via the CLI.
kamimai
is written in Go, so if you have Go installed you can install it with go get:
go get github.com/eure/kamimai/cmd/kamimai
Make sure that kamimai
was installed correctly:
kamimai -h
# create new migration files
kamimai -path=./examples/mysql -env=test1 create migrate_name
# apply all available migrations
kamimai -path=./examples/mysql -env=test1 up
# apply the next n migrations
kamimai -path=./examples/mysql -env=test1 up n
# apply the given version migration
kamimai -path=./examples/mysql -env=test1 up -version=20060102150405
# rollback the previous migration
kamimai -path=./examples/mysql -env=test1 down
# rollback the previous n migrations
kamimai -path=./example/mysql -env=test1 down n
# rollback the given version migration
kamimai -path=./examples/mysql -env=test1 down -version=20060102150405
# sync all migrations
kamimai -path=./examples/mysql -env=test1 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
docker-compose up -d
# kamimai の実行
MYSQL_HOST=127.0.0.1 MYSQL_USER=kamimai MYSQL_PASSWORD=kamimai go run ./cmd/kamimai --dry-run --env=development --path=./examples/mysql create test1
kamimai: created examples/mysql/migrations/002_test_up.sql
kamimai: created examples/mysql/migrations/002_test_down.sql