Skip to content
/ kamimai Public
forked from eure/kamimai

紙舞 - A migration manager written in Golang.

License

Notifications You must be signed in to change notification settings

Fs02/kamimai

 
 

Repository files navigation

Kamimai - 紙舞

A migration manager written in Golang. Use it in run commands via the CLI. This fork support cli without the needs of configuration file.

GoDoc Build Status codecov Go Report Card

Installation

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

Usage:

Create

# create new migration files
kamimai --driver=mysql --dsn="mysql://user:password@(host:port)/database" --directory=./db/migrations create migrate_name

Up

# 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

Down

# 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

# sync all migrations
kamimai --driver=mysql --dsn="mysql://user:password@(host:port)/database" --directory=./db/migrations 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

  • MySQL

Plan

  • SQLite
  • PostgreSQL
  • and more

License

The MIT License (MIT)

About

紙舞 - A migration manager written in Golang.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 93.3%
  • Makefile 6.7%