Skip to content

Package migration for Golang automatically handles versioning of a database schema by applying a series of migrations supplied by the client.

License

Notifications You must be signed in to change notification settings

BurntSushi/migration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Package migration for Golang automatically handles versioning of a database schema by applying a series of migrations supplied by the client. It uses features only from the database/sql package, so it tries to be driver independent. However, to track the version of the database, it is necessary to execute some SQL. I've made an effort to keep those queries simple, but if they don't work with your database, you may override them.

This package works by applying a series of migrations to a database. Once a migration is created, it should never be changed. Every time a database is opened with this package, all necessary migrations are executed in a single transaction. If any part of the process fails, an error is returned and the transaction is rolled back so that the database is left untouched. (Note that for this to be useful, you'll need to use a database that supports rolling back changes to your schema. Notably, MySQL does not support this, although SQLite and PostgreSQL do.)

The version of a database is defined as the number of migrations applied to it.

Installation

If you have Go installed and your GOPATH is setup, then migration can be installed with go get:

go get github.com/BurntSushi/migration

Documentation

Documentation is available at godoc.org/github.com/BurntSushi/migration.

Unstable

At the moment, I'm still experimenting with the public API, so I may still introduce breaking changes. In general though, I am happy with the overall architecture.

About

Package migration for Golang automatically handles versioning of a database schema by applying a series of migrations supplied by the client.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages