Skip to content

Instantly share code, notes, and snippets.

@humbertodosreis
Forked from stevenyap/Heroku.md
Created October 22, 2019 22:25
Show Gist options
  • Save humbertodosreis/d0eca0429725a41902268540a05e4a70 to your computer and use it in GitHub Desktop.
Save humbertodosreis/d0eca0429725a41902268540a05e4a70 to your computer and use it in GitHub Desktop.
Heroku setup and list of commands

Note that Heroku Config is found in /.git/config
** Make sure you have setup your git properly before pushing to Heroku **

Pre-conditions for app on Heroku

Create an app on Heroku

This is a better way than to create it via heroku.com as it automatically set ./.git/config
Note: Make sure you are in your project folder.

heroku apps:create <app name> # creates an app with the name

Configure your Heroku app name

  • Do this step if you create your Heroku account online
  • Log on to your heroku account
  • Go to your app and change your app name
  • Change your app name in /.git/config [remote "heroku"]
[remote "heroku"]
	url = git@heroku.com:<YOUR_NEW_APP_NAME>.git
	fetch = +refs/heads/*:refs/remotes/heroku/*

Push to heroku

  • Commit master branch to heroku
  • Make sure you have already setup your git
git push heroku master

Setup Database

heroku run rake db:migrate

heroku run rake db:seed # if you need to seed the database

That's it for pushing to Heroku!!


Manage DB on Heroku

To manages your postgres db on heroku, just go to http://postgres.heroku.com

Other Heroku Commands

heroku logs -t # shows heroku server logs (-t for tail)

heroku run rake db:migrate # this is how you send rake cmd to heroku

heroku config # see db config of heroku (to get DB URL)

heroku ps # see processes running

heroku releases # see all releases

heroku pg:reset DATABASE_URL # Drops and creates heroku DB. Note that DATABASE_URL is auto-mapped to your postgres db.

heroku run console # Heroku rails c

heroku restart # Restarts your Heroku dyno

# Puts your app on maintenance
heroku maintenance:on
heroku maintenance:off
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment