How to copy staging data to review app on heroku postgres
I ran into this problem as I was setting up the review app on heroku.
I do have enough seed file to run app, but not enough to run all tests.
Here is how I solved with postdeploy script in app.json
{
"name": "test_app",
"scripts": {
"postdeploy": "pg_dump $STAGING_DATABASE_URL | psql $DATABASE_URL && bundle exec rake db:migrate"
},
"env": {
"STAGING_DATABASE_URL": {
"required": true
},
}
"addons": [
"heroku-postgresql",
],
"buildpacks": [
{
"url": "heroku/ruby"
}
]
}
NOTE: You need to set STAGING_DATABASE_URL
in parent app first
Written by naohiro
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Heroku
Authors
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/47788/e6b625008c816ab3d8d742cc3eddbb00.jpeg)
dommmel
77.52K
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/39096/ca3dc3f93730afb41d6753d8bf010a38.jpeg)
petenicholls
63.57K
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#