20190118064320_devise_create_users.rb 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # frozen_string_literal: true
  2. class DeviseCreateUsers < ActiveRecord::Migration[5.2]
  3. def change
  4. create_table :users do |t|
  5. ## Database authenticatable
  6. t.string :username, null: false, default: ""
  7. t.string :email, null: false, default: ""
  8. t.string :encrypted_password, null: false, default: ""
  9. ## Recoverable
  10. t.string :reset_password_token
  11. t.datetime :reset_password_sent_at
  12. ## Rememberable
  13. t.datetime :remember_created_at
  14. ## Trackable
  15. t.integer :sign_in_count, default: 0, null: false
  16. t.datetime :current_sign_in_at
  17. t.datetime :last_sign_in_at
  18. t.inet :current_sign_in_ip
  19. t.inet :last_sign_in_ip
  20. ## Confirmable
  21. t.string :confirmation_token
  22. t.datetime :confirmed_at
  23. t.datetime :confirmation_sent_at
  24. t.string :unconfirmed_email # Only if using reconfirmable
  25. ## Lockable
  26. t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
  27. t.string :unlock_token # Only if unlock strategy is :email or :both
  28. t.datetime :locked_at
  29. t.timestamps null: false
  30. end
  31. add_index :users, :email, unique: true
  32. add_index :users, :username, unique: true
  33. add_index :users, :reset_password_token, unique: true
  34. add_index :users, :confirmation_token, unique: true
  35. add_index :users, :unlock_token, unique: true
  36. end
  37. end