Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/felixge/pgmigrate
pgmigrate implements a minimalistic migration library for postgres.
https://github.com/felixge/pgmigrate
Last synced: about 2 months ago
JSON representation
pgmigrate implements a minimalistic migration library for postgres.
- Host: GitHub
- URL: https://github.com/felixge/pgmigrate
- Owner: felixge
- License: other
- Created: 2016-12-27T07:28:27.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-20T09:22:48.000Z (about 7 years ago)
- Last Synced: 2024-10-11T15:18:54.277Z (2 months ago)
- Language: Go
- Homepage:
- Size: 11.7 KB
- Stars: 23
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# DEPRECATED - DOT NOT USE
I'm using https://flywaydb.org/ now. It does everything I'd ever want out of a migration tool, except that it's written in Java. Maybe one day I'll port it to Go. But probably not. There is more important stuff to worry about :)
# pgmigrate
[![GoDoc](https://godoc.org/github.com/felixge/pgmigrate?status.svg)](https://godoc.org/github.com/felixge/pgmigrate)
[![Build Status](https://travis-ci.org/felixge/pgmigrate.svg?branch=master)](https://travis-ci.org/felixge/pgmigrate)pgmigrate implements a minimalistic migration library for postgres.
## Example Usage
```go
db, _ := sql.Open("postgres", "postgres://localhost/mydb")
ms, _ := pgmigrate.LoadMigrations(http.Dir("path/to/migrations"))
pgmigrate.DefaultConfig.Migrate(db, ms)
```## Why this package exists
There are a number of decent database migration libraries available for Go,
but I found them to be doing too much in some cases, and too little in others.Specifically pgmigrate is different because:
* **Only works for postgres:** This keeps the code base small and allows
leveraging postgres specific features.
* **Executes all migrations in a single transaction:** This avoids problems
with partially applied migrations.
* **Verifies previously executed migrations have not been modified:** This
reduces the chance of different environments ending up with different
schemas.
* **Does not support down migrations:** This might be controversial, but I
don't find them very useful. If a database change needs to be rolled back,
this can be accomplished by pushing another up migration.
* **No external dependencies:** Some other libs force you to transitively
depend on client libraries for all the databases they support.
* **Configurable schema/table:** Gives you control over where your migration
data is stored.
* **Does not ship with a command line client:** IMO there are just too many
integration scenarios to make a CLI that works for everybody.
* **Supports loading migrations from a virtual `http.FileSystem`:** This works
well when using certain libraries that allow bundling static files into your
Go binary.If the tradeoffs above don't work for you, you're probably better off with one
of the other libraries.## License
MIT