Giter Site home page Giter Site logo

migrate's Introduction

Migrate

Migrate is a DSL for the Go programming lanuage that helps to migrate your SQL database. Migrate is vendor independent and currently SQLite, MySQL and Postgres dialects are supported.

This is experimental software and the API will change.

Usage

type migration struct {
	CreateT1 CreateTable `version:"1"`
	ChangeT1 ChangeTable `version:"2"`
	RemoveT1 RemoveTable `version:"3"`
}

var Migration = &migration{
	CreateT1: func() (*Table, error) {
		return NewTable("t1", func(t *Table) {
			t.Field("id", SERIAL, PrimaryKey)
			t.Field("email", VARCHAR, NotNull)
			t.Field("username", VARCHAR, NotNull)
			t.Field("password", VARCHAR, NotNull)
			t.Field("pin", VARCHAR, Args(4)) // This produces a VARCHAR(4)
		}), nil
	},

	ChangeT1: func() (*Change, error) {
		return NewChange("t1", func(c *Change) {
			c.Remove("pin")
			c.Add("address", TEXT)
		}), nil
	},

	RemoveT1: func() (string, error) {
		return "t1", nil
	},
}

migrate's People

Watchers

Gustavo Chaín 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.