1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-12-18 08:26:45 +02:00
woodpecker/vendor/github.com/BurntSushi/migration
2015-09-29 17:34:44 -07:00
..
doc.go moving from Godeps to Go 1.5 vendoring 2015-09-29 17:34:44 -07:00
Makefile moving from Godeps to Go 1.5 vendoring 2015-09-29 17:34:44 -07:00
migration.go moving from Godeps to Go 1.5 vendoring 2015-09-29 17:34:44 -07:00
README.md moving from Godeps to Go 1.5 vendoring 2015-09-29 17:34:44 -07:00
session.vim moving from Godeps to Go 1.5 vendoring 2015-09-29 17:34:44 -07:00
UNLICENSE moving from Godeps to Go 1.5 vendoring 2015-09-29 17:34:44 -07:00

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.