# SPDX-FileCopyrightText: 2022 Alembic Pty Ltd
#
# SPDX-License-Identifier: MIT

defmodule Example.Repo.Migrations.AddUserWithTokenRequiredResource do
  @moduledoc """
  Updates resources based on their most recent snapshots.

  This file was autogenerated with `mix ash_postgres.generate_migrations`
  """

  use Ecto.Migration

  def up do
    create table(:user_with_token_required, primary_key: false) do
      add :id, :uuid, null: false, default: fragment("uuid_generate_v4()"), primary_key: true
      add :email, :citext, null: false
      add :hashed_password, :text
      add :created_at, :utc_datetime_usec, null: false, default: fragment("now()")
      add :updated_at, :utc_datetime_usec, null: false, default: fragment("now()")
    end

    create unique_index(:user_with_token_required, [:email],
             name: "user_with_token_required_email_index"
           )
  end

  def down do
    drop_if_exists unique_index(:user_with_token_required, [:email],
                     name: "user_with_token_required_email_index"
                   )

    drop table(:user_with_token_required)
  end
end