I\'m in the process of adding Devise to an existing Rails app, with a Users table already defined. The devise generator pushed out the following migration:
class
To alter a table and/or its indeces use #change_table inside #change
action of a migration. Then you be able to create reversable index removal as follows:
def change
change_table :users do |t|
t.index :email, :unique => true
t.index :reset_password_token, :unique => true
end
end
When you have to drop a table with its index of course with reversable action you can use #drop_table method for SchemaStatements
with the #index method of Table
class for ConnectionAdapter
:
def change
drop_table :users do |t|
t.index :email, :unique => true
t.index :reset_password_token, :unique => true
end
end
In case you have need exactly the #up/down
pair in a migration. Use just a #change_table method along with #remove_index method of Table
class for ConnectionAdapter
:
def up
change_table :users do |t|
t.index :email, :unique => true
t.index :reset_password_token, :unique => true
end
end
def down
change_table :users do |t|
t.remove_index :email, :unique => true
t.remove_index :reset_password_token, :unique => true
end
end
All of the methods are available in Rails
version of 2.1.0
or of earlier ones.