I am trying to add Devise to an existing Rails application with an already defined Users table. The project generator supplanted the following migration:
class AddDeviseToUsers < ActiveRecord::Migration def self.up change_table(:users) do |t| ## Database authenticatable t.string :email, :null => false, :default => "" t.string :encrypted_password, :null => false, :default => "" ## Recoverable t.string :reset_password_token t.datetime :reset_password_sent_at ## Rememberable t.datetime :remember_created_at ## Trackable t.integer :sign_in_count, :default => 0 blah blah blah.... end add_index :users, :email, :unique => true add_index :users, :reset_password_token, :unique => true end
Migration down is not generated, and I have time to delete these indexes. I see various suggestions in the documentation and various suggestions on the Internet, but none of them seem to work for me. For example...
def self.down change_table(:users) do |t| t.remove :email t.remove :encrypted_password t.remove :reset_password_token blah blah blah... end remove_index :users, :email remove_index :users, :reset_password_token end
leads to...
An error has occurred, this and all later migrations canceled: Index name 'index_users_on_email' on table 'users' does not exist
which is odd because if I check the database, I'm pretty sure 'index_users_on_email' is right there ...
I tried other options, including
remove_index :users, :column => :email remove_index :users, 'email'
or
change_table(:users) do |t| t.remove_index :email end
... but without dice. I am running Rails 3.1.0, Ruby 1.9.2, rake 0.9.2.2, with Postgres.
The command that lets me go:
bundle exec rake db:rollback STEP=1
after successful migration. Any tips?