hrishikeshp19
hrishikeshp19

Reputation: 9036

rails migration version issue: any new migration not working

From this morning, I am facing weird issues with Rails devise. Following is output of my ls and rake db version command.

hrishikesh@hrishikesh-ubuntu:~/git-public/personaldiary/db/migrate$ ls -1
20120110083934_devise_create_users.rb
20120110090514_create_posts.rb
20120110090845_add_user_id_to_post.rb
20120203035323_add_confirmable_to_devise.rb
20120203035323_add_confirmable_to_devise.rb~
20120203043601_add_lockable_to_devise.rb
20120203043601_add_lockable_to_devise.rb~
hrishikesh@hrishikesh-ubuntu:~/git-public/personaldiary/db/migrate$ rake db:version
(in /home/hrishikesh/git-public/personaldiary)
DEPRECATION WARNING: require "activerecord" is deprecated and will be removed in Rails 3. Use require "active_record" instead. (called from /usr/lib/ruby/vendor_ruby/activerecord.rb:2)
Current version: 20120203034555
hrishikesh@hrishikesh-ubuntu:~/git-public/personaldiary/db/migrate$ 

If I try to add any new migrations, rake db:migrate throws error that tells me that some column already exists, and fails.

My failing migration code is here:

class AddConfirmableToDevise < ActiveRecord::Migration
  def change
    change_table(:users) do |t|
      t.confirmable
    end
    add_index :users, :confirmation_token,   :unique => true
  end
end

I specifically do not want to use up and down methods because of this

Please help.

Upvotes: 2

Views: 533

Answers (1)

hrishikeshp19
hrishikeshp19

Reputation: 9036

After spending hours to find solution, I decided to give up and ran

rake db:migrate:reset

And it worked, only thing is my data was lost, which was not that big deal at this point.

Thank you everyone for attempting to solve this.

Upvotes: 2

Related Questions