Pregunta

How are you everyone?

I am 'STUCK' in rake migration -

The error message shows -

Migrating to AddDeviseToUsers (20130628040020) == AddDeviseToUsers: migrating =============================================== -- change_table(:users) rake aborted! An error has occurred, this and all later migrations canceled:

PG::Error: ERROR: relation "users" does not exist : ALTER TABLE "users" ADD COLUMN "email" character varying(255) DEFAULT '' NOT NULL/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.12/lib/active_record/connection_adapters/postgresql_adapter.rb:652:in exec' ... /app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.12/lib/active_record/migration.rb:551:in migrate' /app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.12/lib/active_record/railties/databases.rake:179:in `block (2 levels) in ' Tasks: TOP => db:migrate (See full trace by running task with --trace) Optinovations-MacBook-Air:omrails Optinovation$ rake db: migrate rake aborted!

Don't know how to build task 'db:'

https://github.com/optinovation/omrails

Heroku logs:

2013-06-28T04:30:42.808951+00:00 heroku[api]: Starting process with command bundle exec rake db:migrate by hansean@gmail.com 2013-06-28T04:30:48.308515+00:00 heroku[run.8286]: Awaiting client 2013-06-28T04:30:48.353120+00:00 heroku[run.8286]: Starting process with command bundle exec rake db:migrate 2013-06-28T04:30:56.086242+00:00 heroku[run.8286]: State changed from up to complete 2013-06-28T04:30:56.078116+00:00 heroku[run.8286]: Process exited with status 1 2013-06-28T05:31:34.078443+00:00 heroku[web.1]: Idling 2013-06-28T05:31:36.753947+00:00 heroku[web.1]: Stopping all processes with SIGTERM 2013-06-28T05:31:38.664799+00:00 heroku[web.1]: Process exited with status 0 2013-06-28T05:31:38.670876+00:00 heroku[web.1]: State changed from up to down

Help please!

¿Fue útil?

Solución

I cloned your repo and it appears the problem is resulting because your User table already has columns for email and name.

In your db/schema.rb file, you can see the db schema is timestamped (:version => 20130627224008) which is earlier than the 2 pending migration timestamps. The schema.rb timestamp will update if/when the migrations are successful.

The point is that it appears you already have columns for email and name in the User table. Specifically look at lines #35 and #47 in your schema.rb.

The error thrown in the development environment that I saw when running rake:db migrate was, "SQLite3::SQLException: duplicate column name: email: ALTER TABLE "users" ADD "email".

I didn't try to push your app to production, but in my experience PostgreSQL (PG) and SQLite errors can be slightly different for the same issue.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top