Kamimai - 紙舞
A migration manager written in Golang. Use it in run commands via the CLI.
Installation
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
Usage:
Create
# create new migration files
kamimai -path=./example/mysql -env=test1 create migrate_name
Up
# apply all available migrations
kamimai -path=./example/mysql -env=test1 up
# apply the next n migrations
kamimai -path=./example/mysql -env=test1 up n
# apply the given version migration
kamimai -path=./example/mysql -env=test1 up -version=20060102150405
Down
# rollback the previous migration
kamimai -path=./example/mysql -env=test1 down
# rollback the previous n migrations
kamimai -path=./example/mysql -env=test1 down n
# rollback the given version migration
kamimai -path=./example/mysql -env=test1 down -version=20060102150405
Sync
# sync all migrations
kamimai -path=./example/mysql -env=test1 sync
Usage in Go code
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)
// ...
Drivers
Availables
Plan
- SQLite
- PostgreSQL
- and more
License
The MIT License (MIT)