Skip to content
This repository has been archived by the owner on Jul 24, 2021. It is now read-only.

jagregory/mig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mig

GoDoc

Go SQL migration package

Usage

import "github.com/jagregory/mig"

mig.Define(`
	create table foo ( id integer );
`)

mig.DefineVersion(2, `
	create table bar ( id integer );
`)

mig.Migrate(db)

The Define and DefineVersion functions are used to define a migration and the SQL that will be executed for it. The Migrate function actually executes the migrations. An error will be returned from Migrate if anything bad happens.

How it works

Mig will create a db_version table in your database with a version int column. Each migration will be executed in the order they're defined in unless there's a corresponding row in the db_version table. After each successful migration a row will be inserted in db_version for that migration.

About

Go SQL migration package

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages