Search code examples
ruby-on-railsdatabaseruby-on-rails-3herokutaps

How can I make my staging and production have the same data? (Heroku)


I've looked at Heroku's Taps project (http://devcenter.heroku.com/articles/taps) but there's a huge constraint on foreign keys, so I'm uncomfortable with using this.

All I want to do is get my production data safely and put it on my staging app so the two are more closely matched. Advice?


Solution

  • Thoughtbot posted this a few weeks ago:

    You need the pgbackups addon (free), and use this to transfer from production to staging

    heroku addons:add pgbackups --remote staging
    heroku addons:add pgbackups --remote production
    heroku pgbackups:capture --remote production
    heroku pgbackups:restore DATABASE `heroku pgbackups:url --remote production` --remote staging
    

    Gist here: https://gist.github.com/1095522

    Edit: Make sure you have your git branches "staging" and "production" pointing to the heroku apps.

    git remote add production production_heroku_app
    git remote add staging staging_heroku_app