class CreateUsers < ActiveRecord::Migration[8.1]
  def change
    create_table :users do |t|
      t.string :email, null: false
      t.string :password_digest, null: false
      t.string :name
      t.integer :role, null: false, default: 0
      t.string :primary_language
      t.string :invitation_token
      t.datetime :invitation_sent_at
      t.datetime :invitation_accepted_at
      t.references :invited_by, null: true, foreign_key: { to_table: :users }

      t.index :email, unique: true
      t.index :invitation_token, unique: true

      t.timestamps
    end
  end
end
