Created
December 11, 2011 17:45
-
-
Save dgilperez/1461752 to your computer and use it in GitHub Desktop.
Authlogic to Devise Migration (rails3.1)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AuthlogicToDevise < ActiveRecord::Migration | |
def up | |
## Database authenticatable | |
rename_column :users, :crypted_password, :encrypted_password | |
## Recoverable | |
add_column :users, :reset_password_token, :string, :limit => 255 | |
add_column :users, :reset_password_sent_at, :datetime | |
## Rememberable | |
add_column :users, :remember_created_at, :datetime | |
## Trackable | |
rename_column :users, :login_count, :sign_in_count | |
rename_column :users, :current_login_at, :current_sign_in_at | |
rename_column :users, :last_login_at, :last_sign_in_at | |
rename_column :users, :current_login_ip, :current_sign_in_ip | |
rename_column :users, :last_login_ip, :last_sign_in_ip | |
## Encryptable | |
## Confirmable | |
add_column :users, :confirmation_token, :string, :limit => 255 | |
add_column :users, :confirmed_at, :datetime | |
add_column :users, :confirmation_sent_at, :datetime | |
execute "UPDATE users SET confirmed_at = created_at, confirmation_sent_at = created_at" | |
# not using reconfirmable | |
## Lockable | |
rename_column :users, :failed_login_count, :failed_attempts | |
add_column :users, :unlock_token, :string, :limit => 255 | |
add_column :users, :locked_at, :datetime | |
## Token authenticatable | |
add_column :users, :authentication_token, :string, :limit => 255 | |
## cleaning remaining Authlogic stuff | |
remove_column :users, :persistence_token | |
remove_column :users, :perishable_token | |
remove_column :users, :single_access_token | |
## Indexes | |
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 down | |
## Database authenticatable | |
rename_column :users, :encrypted_password, :crypted_password | |
## Recoverable | |
remove_column :users, :reset_password_token | |
remove_column :users, :reset_password_sent_at | |
## Rememberable | |
remove_column :users, :remember_created_at | |
## Trackable | |
rename_column :users, :sign_in_count, :login_count | |
rename_column :users, :current_sign_in_at, :current_login_at | |
rename_column :users, :last_sign_in_at, :last_login_at | |
rename_column :users, :current_sign_in_ip, :current_login_ip | |
rename_column :users, :last_sign_in_ip, :last_login_ip | |
## Encryptable | |
## Confirmable | |
remove_column :users, :confirmation_token | |
remove_column :users, :confirmed_at | |
remove_column :users, :confirmation_sent_at | |
# not using reconfirmable | |
## Lockable | |
rename_column :users, :failed_attempts, :failed_login_count | |
remove_column :users, :unlock_token | |
remove_column :users, :locked_at | |
## Token authenticatable | |
remove_column :users, :authentication_token | |
## cleaning remaining Authlogic stuff | |
add_column :users, :perishable_token, :string, :limit => 255 | |
add_column :users, :single_access_token, :string, :limit => 255 | |
add_column :users, :persistence_token, :string, :limit => 255 | |
## Indexes | |
remove_index :users, :reset_password_token | |
remove_index :users, :confirmation_token | |
remove_index :users, :unlock_token | |
remove_index :users, :authentication_token | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment