1

Heroku Crashing on Rake DB: Migrate

 2 years ago
source link: https://www.codesd.com/item/heroku-crashing-on-rake-db-migrate.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Heroku Crashing on Rake DB: Migrate

advertisements

I have posted a couple other questions about a project I am working on, and I finally got it working to how I want it to.

I uploaded my stuff to heroku, and had to spend a couple hours figuring out how to get rid of all instances of sqlite3 and switch to PG. I got that fixed, but was still getting an error. Turned out to be a migration.

I ran heroku open and got the error page. I ran heroku logs and got this error;

2014-01-08T22:51:29.356850+00:00 app[web.1]: PG::Error: ERROR:  relation "messages" does not exist
2014-01-08T22:51:29.356850+00:00 app[web.1]: LINE 1: SELECT "messages".* FROM "messages"

That error I remembered was for not running your migrations. So I then ran bundle exec rake db:migrate, and then heroku run rake db:migrate and I got the error;

Running `rake db:migrate` attached to terminal... up, run.9247
rake aborted!
Multiple migrations have the name CreateMessages
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/migration.rb:978:in `validate'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/migration.rb:876:in `initialize'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/migration.rb:764:in `new'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/migration.rb:764:in `up'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/migration.rb:742:in `migrate'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/railties/databases.rake:42:in `block (2 levels) in <top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

Originally I had 2 migration files with the same thing because I forgot about migrations. I manually went into db/migrate and deleted one of them. I then did

git add .
git commit -m "message"
git push

then I ran

git push heroku master

to try and get it on the same level, but I still have this error. Does anyone know what I could do to fix this? Any help would be amazing.


FIRST: it's my understanding that you are ok with resetting your db instance. If that's correct, keep reading Option 1:

Option 1:

First reset your db: heroku pg:reset as noted here

Then confirm that you have indeed remove your conflicting migrations. Proceed with any git push if you need.

At this point, re-migrate your db:

heroku run rake db:migrate

Option 2:

Please comment below if you are not planning to reset your DB. It becomes a whole lot trickier then, and the right solution is probably more migrations or roll backs to fix your schema.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK