mirror of https://github.com/pressly/goose.git
Expand environment variables in dbconf.yml's open
The immediate goal here is to make using goose with Heroku easier, where the database connection url is provided by an environment variable. More generally, this makes it easier to avoid committing sensitive information like database credentials.pull/2/head
parent
17747efe29
commit
f787354860
22
README.md
22
README.md
|
@ -124,3 +124,25 @@ A sample dbconf.yml looks like
|
|||
Here, `development` specifies the name of the environment, and the `driver` and `open` elements are passed directly to database/sql to access the specified database.
|
||||
|
||||
You may include as many environments as you like, and you can use the `-env` command line option to specify which one to use. goose defaults to using an environment called `development`.
|
||||
|
||||
goose will expand environment variables in the `open` element. For an example, see the Heroku section below.
|
||||
|
||||
|
||||
## Using goose with Heroku
|
||||
|
||||
goose plays nicely with Heroku. These instructions assume that you're using [Keith Rarick's Heroku Go buildpack](https://github.com/kr/heroku-buildpack-go). First, make sure that Heroku builds the goose executable during deployment by adding an (unused) import to your app:
|
||||
|
||||
import _ "bitbucket.org/liamstask/goose"
|
||||
|
||||
[Set up your Heroku database(s) as usual.](https://devcenter.heroku.com/articles/heroku-postgresql)
|
||||
|
||||
Then make use of environment variable expansion in your `dbconf.yml`, such as:
|
||||
|
||||
production:
|
||||
driver: postgres
|
||||
open: $DATABASE_URL
|
||||
|
||||
To run migrations in production, use `heroku run`, e.g.:
|
||||
|
||||
heroku run goose -env production up
|
||||
|
||||
|
|
Loading…
Reference in New Issue