I’ve currently been using these two commands to copy the db from production to staging:
URL=$(heroku config:get DATABASE_URL -a myapp-production)
heroku pg:copy "$URL" DATABASE_URL -a myapp-staging --confirm myapp-staging
Due to a swelling database I wonder for testing purposes how to replicate only a limited number of rows (of each table) to another database.
A naive solution could be:
1. Download db production -> locally
2. Run script that wipes out data
3. 4 Upload db locally -> staging
This question answers how to download an entire table of a database.