Rake Not Able to Migrate

NOT able to rake db:migrate

You called:

\Users\MEGHA\sagar_blog>rails generate scaffold post title:string \ body:text

remove the excess \:

\Users\MEGHA\sagar_blog>rails generate scaffold post title:string body:text

\ is actually a hard blank, which causes the body field to be called body (with a blank before the name), this causes the migration file to generate a line t.text : body instead of t.text :body, which fails the migration (and probably later will fail other stuff as well).

Stuck in rake migration

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.

rails rake db:migrate migration partially done and need to be redone from scratch

You can reset database back to the original state using the following command and run the migration again.

rake db:reset


Related Topics



Leave a reply



Submit