Drop/Create/Migrate Postgres Database On Heroku

I’m ALWAYS forgetting how to reset the postgres database on Heroku, because the typical rake db:drop/create/migrate won’t work on the Heroku command line. This is 99% for my own future reference, but to reset the database on Heroku:

  1.  heroku pg:reset
    •  it will ask you to type in your heroku url, follow the directions and do so!
  2.  heroku run rake db:migrate
    •  this may take a little while!

Easy breezy, I just always forget it!

Deploying Rails to Heroku

While deploying an initial version of Crapper Keeper, I ran into a problem with Heroku.  Deploying to Heroku is super easy, since you just have to deploy a Github branch and the site is live a few moments later.  My app, which was running well locally, suddenly was having database problems.

Crapper Keeper is a Ruby on Rails app.  Rails comes with SQLite out of the box, but Heroku doesn’t support SQLite.  So after a lot of searching, I was able to find a way to change the database from SQLite to PostgreSQL.  One guide I found handy was on Stack Overflow and here.

One tip, that I forgot, was that you have to make the database but then also remember to migrate the database, using rake db:migrate