defmodule Realworld.Repo.Migrations.CreateFollows 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(:follows, primary_key: false) do
      add :id, :uuid, null: false, primary_key: true
      add :created_at, :utc_datetime_usec, null: false, default: fragment("now()")

      add :user_id,
          references(:users,
            column: :id,
            name: "follows_user_id_fkey",
            type: :uuid,
            prefix: "public"
          ),
          primary_key: true,
          null: false

      add :target_id,
          references(:users,
            column: :id,
            name: "follows_target_id_fkey",
            type: :uuid,
            prefix: "public"
          ),
          primary_key: true,
          null: false
    end
  end

  def down do
    drop constraint(:follows, "follows_target_id_fkey")

    drop constraint(:follows, "follows_user_id_fkey")

    drop table(:follows)
  end
end