Name: migrate
Owner: 2GIS
Description: Database migrations. CLI and Golang library.
Created: 2018-03-15 02:10:12.0
Updated: 2018-03-15 05:37:40.0
Pushed: 2018-03-15 05:37:38.0
Size: 488
Language: Go
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Database migrations written in Go. Use as CLI or import as library.
Looking for v1?
Database drivers run migrations. Add a new database?
Source drivers read migrations from local or remote sources. Add a new source?
ew install migrate --with-postgres
grate -database postgres://localhost:5432/database up 2
GracefulStop chan bool
.io.Reader
streams internally for low memory overhead.rt (
"github.com/mattes/migrate"
_ "github.com/mattes/migrate/database/postgres"
_ "github.com/mattes/migrate/source/github"
main() {
m, err := migrate.New(
"github://mattes:personal-access-token@mattes/migrate_test",
"postgres://localhost:5432/database?sslmode=enable")
m.Steps(2)
Want to use an existing database client?
rt (
"database/sql"
_ "github.com/lib/pq"
"github.com/mattes/migrate"
"github.com/mattes/migrate/database/postgres"
_ "github.com/mattes/migrate/source/file"
main() {
db, err := sql.Open("postgres", "postgres://localhost:5432/database?sslmode=enable")
driver, err := postgres.WithInstance(db, &postgres.Config{})
m, err := migrate.NewWithDatabaseInstance(
"file:///migrations",
"postgres", driver)
m.Steps(2)
Each migration has an up and down migration. Why?
574547_create_users_table.up.sql
574547_create_users_table.down.sql
Best practices: How to write migrations.
Yes, please! Makefile
is your friend,
read the development guide.
Also have a look at the FAQ.
Looking for alternatives? https://awesome-go.com/#database.