Heroku Error After Deploying Database Changes (Add, Drop, Modify, etc)

Home / Blog / Heroku Error After Deploying Database Changes (Add, Drop, Modify, etc)


In my local Ruby on Rails project, I ran into an issue after making some changes to the database. Something got screwed up my newly created resource pins, so to fix that I:

1. destroyed the resource

$ rails destroy scaffold pins

2. created a migration file to drop the tables associated with it

$ rails generate migration DropPinsTable

3. Added the this content to the newly created migration file:

class DropPinsTable < ActiveRecord::Migration
 def up
 drop_table :pins
def down
 raise ActiveRecord::IrreversibleMigration

4. ran the migration

$ rake db:migrate

5. Regenerated the resource

$ rails generate scaffold pins

New tables were automatically created again, but they were using the same name as the resource I just destroyed. I had a suspicion this might cause an issue when deploying to heroku, and it did.


After running git push heroku master and heruoku run rake db:migrate, I saw this error when visiting the index page for my newly created resource on heroku:

Screen Shot 2014-11-26 at 12.07.47 PM



The fix turned out to be much easier than I expected, thanks to some sage advice found on stackoverlow.

All I had to do was reset the database:

$ rails heroku run db:reset

After that everything worked fine, no error message. Magic!

Recent Posts
Contact Us

We're not around right now. But you can send us an email and we'll get back to you, asap.