Help us shape the future of Go! Take the 2026 Go Developer Survey

mygrate

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 15, 2019 License: MIT Imports: 0 Imported by: 0

README

go-mygrate

Mμgrate

Mμgrate is a micro (μ) migration framework. It has no external deps, use go stdlib features and is production ready. A mμgration is just a timestamp, a name and a pair of go functions executed in order.

Mμgrate is for anyone looking for a simple, small and handy solution to migrate things in your project up and down.

Features

  • ship your migrations compiled in your binary
  • migrate programmatically
  • no need to install some outdated or abandoned ORM to migrate your database
  • use the deps and driver that you are already using
  • migrate whatever you want! A migration is just a pair of functions which getting called in order!
  • ships with a json file based store, but you can implement your own Store
    (sqlite will come soon)
  • the cli works perfectly with go generate to register automatically new migrations files
  • the cli creates new files for you
Installation
CLI

This will install the mygrate command

go get github.com/stahlstift/go-migrate/cmd/mygrate
GO

Add mygrate as a dep to your project

go get github.com/stahlstift/go-migrate

For a complete example see the example folder


//go:generate mygrate generate

func migrate() error {
	myg, err := mygrate.New(&mygrations.Deps{})
	if err != nil {
		return err
	}

	mygrations.Register(myg)

	err = myg.Up(false)
	if err != nil {
		return err
	}

	return nil
}
Usage
mygrate create name_your_migration

Documentation

Overview

Mμgrate is a tool which runs functions in order to migrate anything you want programmatically.

Installation

go get github.com/stahlstift/go-mygrate

Directories

Path Synopsis
_example
demo command
cmd
mygrate command
The CLI for Mμgrate.
The CLI for Mμgrate.
internal
pkg
mygrate
Package mygrate provides the programmatically interface for Mμgrate
Package mygrate provides the programmatically interface for Mμgrate

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL