I'd like to copy a staging/production database to my review apps on creation.
Copying full database contents from parent to Review apps (similar to heroku fork) is not currently supported. Copying production data to test apps means the risk of data leaks or other programming mistakes operating on recent customer data. For those reasons, we instead recommend seeding databases comprehensively with non-production data using seed scripts run with the postdeploy command.
However, a few workarounds are as follows:
Attach your staging database to Review Apps using
heroku addons:attach, if no destructive actions (such as database migrations) will run as part of your Review Apps checks or deployments
Copy the latest backup of your staging database to your Review App database, using
heroku pg:backups:restoreor even
curl <review app url> | pg_restore --verbose --clean --no-acl --no-owner --dbname $DATABASE_URLin a
You can run these commands from your computer, and also through a one-off dyno where you will need to install the Heroku CLI first. To do so you can try this unofficial buildpack: https://github.com/heroku/heroku-buildpack-cli
Another option to run these tasks is to use the release phase which runs after the app is deployed: https://devcenter.heroku.com/articles/release-phase
We recommend only doing this when you can ensure that your staging database contains a safe set of data and not a production fork, so that the worries around data leaks are lessened.