class CreatePillowfortTokens < ActiveRecord::Migration[5.1]
  def change
    create_table :pillowfort_tokens do |t|
      t.integer     :resource_id,     null: false
      t.string      :type,            null: false,  default: 'session'
      t.string      :secret,          null: false
      t.string      :realm,           null: false,  default: 'application'
      t.datetime    :created_at,      null: false
      t.datetime    :expires_at,      null: false
      t.datetime    :confirmed_at,    null: true
    end

    add_index :pillowfort_tokens,
                [:resource_id, :type, :realm],
                unique: true,
                name: :udx_pillowfort_tokens_on_rid_type_and_realm

    add_index :pillowfort_tokens,
                [:type, :secret],
                unique: true,
                name: :udx_pillowfort_tokens_on_type_and_secret
  end
end
