I ran into this same issue and here is how I solved it.
-
Set up the database url you want to copy from as an environment variable on the base app for the pipeline. In my case this is
STAGING_DATABASE_URL
. The url format ispostgresql://username:password@host:port/db_name
. -
In your
app.json
file make sure to copy that variable over. -
In your
app.json
provision a new database which will set theDATABASE_URL
environment variable. -
Use the following script to copy over the database
pg_dump $STAGING_DATABASE_URL | psql $DATABASE_URL
Here is my app.json
file for reference:
{
"name": "app-name",
"scripts": {
"postdeploy": "pg_dump $STAGING_DATABASE_URL | psql $DATABASE_URL && bundle exec rake db:migrate"
},
"env": {
"STAGING_DATABASE_URL": {
"required": true
},
"HEROKU_APP_NAME": {
"required": true
}
},
"formation": {
"web": {
"quantity": 1,
"size": "hobby"
},
"resque": {
"quantity": 1,
"size": "hobby"
},
"scheduler": {
"quantity": 1,
"size": "hobby"
}
},
"addons": [
"heroku-postgresql:hobby-basic",
"papertrail",
"rediscloud"
],
"buildpacks": [
{
"url": "heroku/ruby"
}
]
}