20191018075555_devise_create_users.rb 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # frozen_string_literal: true
  2. class DeviseCreateUsers < ActiveRecord::Migration[6.0]
  3. def change
  4. create_table :users do |t|
  5. ## Database authenticatable
  6. t.string :username
  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. # Only if lock strategy is :failed_attempts
  27. t.integer :failed_attempts, default: 0, null: false
  28. # Only if unlock strategy is :email or :both
  29. t.string :unlock_token
  30. t.datetime :locked_at
  31. ## Omniauthable
  32. t.string :provider
  33. t.string :uid
  34. t.timestamps null: false
  35. end
  36. add_index :users, :email, unique: true
  37. add_index :users, :reset_password_token, unique: true
  38. add_index :users, :confirmation_token, unique: true
  39. add_index :users, :unlock_token, unique: true
  40. end
  41. end