All Projects → BurntSushi → Migration

BurntSushi / Migration

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

Programming Languages

go
31211 projects - #10 most used programming language

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].