Saturday, August 6, 2011

PGError: ERROR: cached plan must not change result type... Solved

I got this error recently after deploying to Heroku:

ActiveRecord::StatementInvalid (PGError: ERROR:  cached plan must not change result type

It turns out the issue was just like that of this person: http://stackoverflow.com/questions/2783813/postgres-8-3-error-cached-plan-must-not-change-result-type.

Basically, I ran a migration / modified my database table, but didn't restart the heroku app. So, after running

heroku run rake db:migrate

I had to also run

heroku restart

and the problem was solved.

Why do we have to do this? According to this site on Heroku, "After running a migration you’ll want to restart your app with heroku restart to reload the schema and pickup any schema changes."

8 comments:

  1. Thanks! I just ran into this problem and this solved it for me.

    ReplyDelete
  2. this saved me! thanks!

    ReplyDelete
  3. yep, your link was the top search result (query = this error's text) and fixed my problem, thanks for posting

    ReplyDelete
  4. thanks just saved me from a heart attack!

    ReplyDelete
  5. Thanks Man! :-) You saved my bacons!

    ReplyDelete
  6. thanks dude worked

    ReplyDelete
  7. you have no idea how happy this just made me. thank you!

    ReplyDelete

Please be considerate in what you say.