Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/freeformz/pajamas


https://github.com/freeformz/pajamas

Last synced: 7 days ago
JSON representation

Awesome Lists containing this project

README

        

# Migration Example App

This app doesn't contain any migrations, but is an example of using [migrate][migrate] with [godep][godep] and [heroku][heroku].

[godep][godep] only includes files from packages imported in your code. When we want to use a migration tool to help automate database migrations we don't have easy access to the cli commands they provide in the dyno. It's sub optimal to have to run those commands from a local system.

Luckily most of the migration tools are fairly well factored and you can lift their main cli bits out of their packages and into your application. This repo is an example of that.

Using `github.com/mattes/migrate` as an example this repo was constructed by doing the following:

1. `cd `
1. Write your code. Simulated with a simple `main.go` here.
1. `go get -u github.com/mattes/migrate`
1. `mkdir -p cmd/migrate`
1. `cp $GOPATH/src/github.com/mattes/migrate/{main,version}.go cmd/migrate`
1. `godep save -r ./...`
1. `git add -A .`
1. `git commit -am "includes migration"`
1. `git push heroku master`

Pushing this repo to a heroku application will produce 2 binaries in `/bin`: `pajamas` and `mirgate`.

Using `heroku run migrate ` then allows you to process any otherwise recorded migrations.

FWIW: I consider this a workaround looking for a better, longer term solution.

[migrate]: https://github.com/mattes/migrate
[godep]: https://github.com/tools/godep
[heroku]: https://heroku.com