After installing devise MODEL User i got this.
class DeviseCreateUsers < ActiveRecord::Migration
def self.up
create_table(:users) do |t|
t.database_authenticatable :null => false
t.recoverable
t.rememberable
t.trackable
# t.encryptable
# t.confirmable
# t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
# t.token_authenticatable
t.timestamps
end
add_index :users, :email, :unique => true
add_index :users, :reset_password_token, :unique => true
# add_index :users, :confirmation_token, :unique => true
# add_index :users, :unlock_token, :unique => true
# add_index :users, :authentication_token, :unique => true
end
def self.down
drop_table :users
end
end
Now if i do rake db:migrate the users table will be created.
How can i revert this migration, i.e. how can I delete the users table using rake again ?
I believe there are three options available for reverting migrations (they also overlap):
Roll down the most recent migration:
rake db:migrate:down
# Rails 2 only.Roll down a number(n) of recent migrations:
rake db:rollback STEP=n
Roll down to a previous, specific version:
$ rake db:migrate:down VERSION=nnn
# Rails 3 (provide version number also).Version Number means the SHA(Secure Hash Algorithm) for the commit which is a long hexadecimal number which looks something like 886af3194768917c78e... You can see it by doing
git log
You can see these commands (and others) with their descriptions by using
rake -T db:
which for rails 3.2 includes:You can do rollback and specify how many last migrations will be rollbacked, e.g.
for 3 last migrations.