GithubHelp home page GithubHelp logo

om732 / kamimai Goto Github PK

View Code? Open in Web Editor NEW

This project forked from eure/kamimai

0.0 2.0 0.0 611 KB

紙舞 - A migration manager written in Golang.

License: MIT License

Makefile 4.85% Go 94.65% Dockerfile 0.51%

kamimai's Introduction

Kamimai - 紙舞

A migration manager written in Golang. Use it in run commands via the CLI.

GoDoc 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/om732/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

Status

# show migration history
kamimai -path=./example/mysql -env=test1 status
+---------+---------+
| VERSION |  STATE  |
+---------+---------+
|     002 | Pending |
|     001 | Applyed |
+---------+---------+

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

Contribution

Setup

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 test
kamimai: created examples/mysql/migrations/002_test_up.sql
kamimai: created examples/mysql/migrations/002_test_down.sql

License

The MIT License (MIT)

kamimai's People

Contributors

kaneshin avatar om732 avatar makotano avatar emahiro avatar gotokatsuya avatar marnie-eure avatar mr04vv avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.