Permalink
Browse files

Added migration for adding confirmable to users

  • Loading branch information...
rhardih committed Jun 3, 2014
1 parent eedaab8 commit 862a3e8d5cb84a577e4181ff65bbde010f90aa90
Showing with 25 additions and 1 deletion.
  1. +20 −0 db/migrate/20140603175035_add_confirmable_to_devise.rb
  2. +5 −1 db/schema.rb
@@ -0,0 +1,20 @@
class AddConfirmableToDevise < ActiveRecord::Migration
# Note: You can't use change, as User.update_all with fail in the down migration
def self.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 # Only if using reconfirmable
add_index :users, :confirmation_token, :unique => true
# User.reset_column_information # Need for some types of updates, but not for update_all.
# To avoid a short time window between running the migration and updating all existing
# users as confirmed, do the following
User.update_all(:confirmed_at => Time.now)
# All existing user accounts should be able to log in after this.
end
def self.down
remove_columns :users, :confirmation_token, :confirmed_at, :confirmation_sent_at
# remove_columns :users, :unconfirmed_email # Only if using reconfirmable
end
end
View
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20140603174508) do
ActiveRecord::Schema.define(version: 20140603175035) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -29,8 +29,12 @@
t.string "last_sign_in_ip"
t.datetime "created_at"
t.datetime "updated_at"
t.string "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
end
add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree
add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree

0 comments on commit 862a3e8

Please sign in to comment.