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

defmodule AshPostgres.TestRepo.Migrations.MigrateResources20 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
    alter table(:temp_entities, prefix: "temp") do
      modify(:updated_at, :utc_datetime_usec, default: fragment("(now() AT TIME ZONE 'utc')"))
      modify(:inserted_at, :utc_datetime_usec, default: fragment("(now() AT TIME ZONE 'utc')"))
    end

    alter table(:records) do
      modify(:updated_at, :utc_datetime_usec, default: fragment("(now() AT TIME ZONE 'utc')"))
      modify(:inserted_at, :utc_datetime_usec, default: fragment("(now() AT TIME ZONE 'utc')"))
    end

    alter table(:posts) do
      modify(:updated_at, :utc_datetime_usec, default: fragment("(now() AT TIME ZONE 'utc')"))
      modify(:created_at, :utc_datetime_usec, default: fragment("(now() AT TIME ZONE 'utc')"))
    end

    alter table(:post_views) do
      modify(:time, :utc_datetime_usec, default: fragment("(now() AT TIME ZONE 'utc')"))
    end

    alter table(:entities) do
      modify(:updated_at, :utc_datetime_usec, default: fragment("(now() AT TIME ZONE 'utc')"))
      modify(:inserted_at, :utc_datetime_usec, default: fragment("(now() AT TIME ZONE 'utc')"))
    end

    alter table(:complex_calculations_documentations) do
      modify(:updated_at, :utc_datetime_usec, default: fragment("(now() AT TIME ZONE 'utc')"))
      modify(:inserted_at, :utc_datetime_usec, default: fragment("(now() AT TIME ZONE 'utc')"))
    end

    alter table(:complex_calculations_channels) do
      modify(:updated_at, :utc_datetime_usec, default: fragment("(now() AT TIME ZONE 'utc')"))
      modify(:created_at, :utc_datetime_usec, default: fragment("(now() AT TIME ZONE 'utc')"))
    end

    alter table(:complex_calculations_certifications_channel_members) do
      modify(:updated_at, :utc_datetime_usec, default: fragment("(now() AT TIME ZONE 'utc')"))
      modify(:created_at, :utc_datetime_usec, default: fragment("(now() AT TIME ZONE 'utc')"))
    end

    alter table(:comments) do
      modify(:created_at, :utc_datetime_usec, default: fragment("(now() AT TIME ZONE 'utc')"))
    end
  end

  def down do
    alter table(:comments) do
      modify(:created_at, :utc_datetime_usec, default: fragment("now()"))
    end

    alter table(:complex_calculations_certifications_channel_members) do
      modify(:created_at, :utc_datetime_usec, default: fragment("now()"))
      modify(:updated_at, :utc_datetime_usec, default: fragment("now()"))
    end

    alter table(:complex_calculations_channels) do
      modify(:created_at, :utc_datetime_usec, default: fragment("now()"))
      modify(:updated_at, :utc_datetime_usec, default: fragment("now()"))
    end

    alter table(:complex_calculations_documentations) do
      modify(:inserted_at, :utc_datetime_usec, default: fragment("now()"))
      modify(:updated_at, :utc_datetime_usec, default: fragment("now()"))
    end

    alter table(:entities) do
      modify(:inserted_at, :utc_datetime_usec, default: fragment("now()"))
      modify(:updated_at, :utc_datetime_usec, default: fragment("now()"))
    end

    alter table(:post_views) do
      modify(:time, :utc_datetime_usec, default: fragment("now()"))
    end

    alter table(:posts) do
      modify(:created_at, :utc_datetime_usec, default: fragment("now()"))
      modify(:updated_at, :utc_datetime_usec, default: fragment("now()"))
    end

    alter table(:records) do
      modify(:inserted_at, :utc_datetime_usec, default: fragment("now()"))
      modify(:updated_at, :utc_datetime_usec, default: fragment("now()"))
    end

    alter table(:temp_entities, prefix: "temp") do
      modify(:inserted_at, :utc_datetime_usec, default: fragment("now()"))
      modify(:updated_at, :utc_datetime_usec, default: fragment("now()"))
    end
  end
end
