Hey everyone,
This is just a quick guide on how to create a test/staging environment with Heroku.
-- Create staging environment heroku create --remote staging -- Push to staging app heroku push staging master -- Run rake db:migrate on staging app heroku run rake db:migrate --remote staging -- Add pgbackups add ons heroku addons:add pgbackups --remote staging heroku addons:add pgbackups --remote heroku -- Create backup of production data heroku pgbackups:capture --remote heroku -- Copy to staging environemnt heroku pgbackups:restore DATABASE `heroku pgbackups:url --remote heroku` --remote staging -- Create a new config file called staging.rb (/config/environments/staging.rb) -- Add environment variables heroku config:add RACK_EVN=staging RAILS_ENV=staging --remote staging -- Ready to go !
For those of you using git branches etc, the following may come in handy as well:
-- Create local development branch git branch development -- Switch to dev branch git checkout development -- Make your changes and commit them git init git add . git commit -m "My changes" -- Push to staging environment (local development branch to staging environment master branch) git push staging development:master
If you run into any trouble, I found the following links pretty helpful:
http://stackoverflow.com/a/6931462/522859
https://devcenter.heroku.com/articles/pgbackups#transfer
https://devcenter.heroku.com/articles/multiple-environments
Let me know if you’ve got anything to add.
Leave a Reply