defmodule Realworld.Repo.Migrations.ArticleTagReferences 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
    drop constraint(:article_tags, "article_tags_tag_id_fkey")

    drop constraint(:article_tags, "article_tags_article_id_fkey")

    alter table(:article_tags) do
      modify :article_id,
             references(:articles,
               column: :id,
               prefix: "public",
               name: "article_tags_article_id_fkey",
               type: :uuid,
               on_delete: :delete_all
             )
    end

    alter table(:article_tags) do
      modify :tag_id,
             references(:tags,
               column: :id,
               prefix: "public",
               name: "article_tags_tag_id_fkey",
               type: :uuid,
               on_delete: :delete_all
             )
    end
  end

  def down do
    drop constraint(:article_tags, "article_tags_tag_id_fkey")

    alter table(:article_tags) do
      modify :tag_id,
             references(:tags,
               column: :id,
               prefix: "public",
               name: "article_tags_tag_id_fkey",
               type: :uuid
             )
    end

    drop constraint(:article_tags, "article_tags_article_id_fkey")

    alter table(:article_tags) do
      modify :article_id,
             references(:articles,
               column: :id,
               prefix: "public",
               name: "article_tags_article_id_fkey",
               type: :uuid
             )
    end
  end
end