20160305115639_add_devise_to_users.rb 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # frozen_string_literal: true
  2. class AddDeviseToUsers < ActiveRecord::Migration[4.2]
  3. def up
  4. change_table(:users, bulk: true) do |t|
  5. ## Database authenticatable
  6. t.string :encrypted_password, null: false, default: ''
  7. ## Recoverable
  8. t.string :reset_password_token
  9. t.datetime :reset_password_sent_at
  10. ## Rememberable
  11. t.datetime :remember_created_at
  12. ## Trackable
  13. t.integer :sign_in_count, default: 0, null: false
  14. t.datetime :current_sign_in_at
  15. t.datetime :last_sign_in_at
  16. t.inet :current_sign_in_ip
  17. t.inet :last_sign_in_ip
  18. end
  19. add_index :users, :reset_password_token, unique: true
  20. end
  21. def down
  22. remove_index :users, :reset_password_token
  23. remove_column :users, :encrypted_password
  24. remove_column :users, :reset_password_token
  25. remove_column :users, :reset_password_sent_at
  26. remove_column :users, :remember_created_at
  27. remove_column :users, :sign_in_count
  28. remove_column :users, :current_sign_in_at
  29. remove_column :users, :current_sign_in_ip
  30. remove_column :users, :last_sign_in_at
  31. remove_column :users, :last_sign_in_ip
  32. end
  33. end