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

defmodule AshPostgres.TestRepo.Migrations.MigrateResources57 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(:unrelated_reports, primary_key: false) do
      add(:id, :uuid, null: false, default: fragment("gen_random_uuid()"), primary_key: true)
      add(:title, :text)
      add(:author_name, :text)
      add(:score, :bigint)

      add(:inserted_at, :utc_datetime,
        null: false,
        default: fragment("(now() AT TIME ZONE 'utc')")
      )
    end

    create table(:unrelated_users, primary_key: false) do
      add(:id, :uuid, null: false, default: fragment("gen_random_uuid()"), primary_key: true)
      add(:name, :text)
      add(:age, :bigint)
      add(:email, :text)
      add(:role, :text, default: "user")
    end

    create table(:unrelated_profiles, primary_key: false) do
      add(:id, :uuid, null: false, default: fragment("gen_random_uuid()"), primary_key: true)
      add(:name, :text)
      add(:age, :bigint)
      add(:bio, :text)
      add(:active, :boolean, default: true)
      add(:owner_id, :uuid)
    end

    create table(:unrelated_secure_profiles, primary_key: false) do
      add(:id, :uuid, null: false, default: fragment("gen_random_uuid()"), primary_key: true)
      add(:name, :text)
      add(:age, :bigint)
      add(:active, :boolean, default: true)
      add(:owner_id, :uuid)
      add(:department, :text)
    end
  end

  def down do
    drop(table(:unrelated_secure_profiles))

    drop(table(:unrelated_profiles))

    drop(table(:unrelated_users))

    drop(table(:unrelated_reports))
  end
end
