Tuesday, 8 March 2016

Useful Heroku commands

Here is a list of my most commonly used Heroku commands for managing a rails application.

LOGIN

heroku login

DATABASES

To create a hobby dev free postgres db
heroku addons:create heroku-postgresql:hobby-dev

To drop the database, if you are using SHARED_DATABASE_URL:
heroku pg:reset DATABASE

To recreate the database with nothing in it
heroku run rake db:migrate

To populate the database with your seed data:
heroku run rake db:seed

You can combine the last two into one action by executing this
heroku run rake db:setup

DEBUGGING

heroku logs

Real time tail
heroku logs --tail


ENV VARIABLES

To set an ENV variable
heroku config:set GITHUB_USERNAME=joesmith

To view all the ENV vars 
heroku config

To view a specifig ENV var
heroku config:get GITHUB_USERNAME 

To unset an  ENV var
heroku config:unset GITHUB_USERNAME