defmodule WhoNeedHelp.Repo.Migrations.CreateAuthIdentities do
  use Ecto.Migration

  def change do
    create table(:auth_identities, primary_key: false) do
      add :id, :binary_id, primary_key: true
      add :provider, :string, null: false
      add :provider_uid, :string, null: false
      add :email, :string, null: false
      add :user_id, references(:users, type: :binary_id, on_delete: :delete_all), null: false

      timestamps(type: :utc_datetime)
    end

    create unique_index(:auth_identities, [:provider, :provider_uid])
    create unique_index(:auth_identities, [:user_id, :provider])
  end
end
