# SPDX-FileCopyrightText: 2020 Zach Daniel
#
# SPDX-License-Identifier: MIT

defmodule AshPostgres.TestRepo.Migrations.MigrateResources17 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(:post_followers, primary_key: false) do
      add :id, :uuid, null: false, default: fragment("uuid_generate_v4()"), primary_key: true

      add :post_id,
          references(:posts,
            column: :id,
            name: "post_followers_post_id_fkey",
            type: :uuid,
            prefix: "public"
          ),
          null: false

      add :user_id,
          references(:users,
            column: :id,
            name: "post_followers_user_id_fkey",
            type: :uuid,
            prefix: "public"
          ),
          null: false
    end
  end

  def down do
    drop constraint(:post_followers, "post_followers_post_id_fkey")

    drop constraint(:post_followers, "post_followers_user_id_fkey")

    drop table(:post_followers)
  end
end