2017-06-30 16:23:28 +08:00
|
|
|
class AddConfirmableToDevise < ActiveRecord::Migration[4.2]
|
2016-02-12 23:52:43 +08:00
|
|
|
def up
|
|
|
|
add_column :users, :confirmation_token, :string
|
|
|
|
add_column :users, :confirmed_at, :datetime
|
|
|
|
add_column :users, :confirmation_sent_at, :datetime
|
|
|
|
add_column :users, :unconfirmed_email, :string
|
|
|
|
add_index :users, :confirmation_token, unique: true
|
|
|
|
|
|
|
|
# SQlite All existing user accounts should be able to log in after this.
|
|
|
|
execute("UPDATE users SET confirmed_at = date('now')")
|
|
|
|
|
|
|
|
# For postgres
|
|
|
|
#execute("UPDATE users SET confirmed_at = NOW()")
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
remove_columns :users, :confirmation_token, :confirmed_at, :confirmation_sent_at
|
|
|
|
remove_columns :users, :unconfirmed_email
|
|
|
|
end
|
|
|
|
end
|