defmodule Animina.Repo.Migrations.AddIndexesToResourcesUsedInFastUser 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_if_not_exists index(:users, [:zip_code])

    create_if_not_exists index(:users, [:is_private])

    create_if_not_exists index(:users, [:created_at])

    create_if_not_exists index(:users, [:gender])

    create_if_not_exists index(:users, [:state])

    create_if_not_exists index(:users, [:registration_completed_at])

    create_if_not_exists index(:user_roles, [:user_id])

    create_if_not_exists index(:user_roles, [:role_id])

    create_if_not_exists index(:traits_flags, [:category_id])

    create_if_not_exists index(:stories, [:user_id])

    create_if_not_exists index(:stories, [:headline_id])

    create_if_not_exists index(:reactions, [:receiver_id])

    create_if_not_exists index(:reactions, [:sender_id])

    create_if_not_exists index(:photos, [:user_id])

    create_if_not_exists index(:photos, [:story_id])

    create_if_not_exists index(:photo_flags, [:flag_id])

    create_if_not_exists index(:photo_flags, [:user_id])

    create_if_not_exists index(:photo_flags, [:photo_id])

    create_if_not_exists index(:optimized_photos, [:user_id])

    create_if_not_exists index(:optimized_photos, [:photo_id])

    create_if_not_exists index(:geo_data_cities, [:zip_code])

    create_if_not_exists index(:credits, [:user_id])

    create_if_not_exists index(:credits, [:donor_id])
  end

  def down do
    drop_if_exists index(:credits, [:donor_id])

    drop_if_exists index(:credits, [:user_id])

    drop_if_exists index(:geo_data_cities, [:zip_code])

    drop_if_exists index(:optimized_photos, [:photo_id])

    drop_if_exists index(:optimized_photos, [:user_id])

    drop_if_exists index(:photo_flags, [:photo_id])

    drop_if_exists index(:photo_flags, [:user_id])

    drop_if_exists index(:photo_flags, [:flag_id])

    drop_if_exists index(:photos, [:story_id])

    drop_if_exists index(:photos, [:user_id])

    drop_if_exists index(:reactions, [:sender_id])

    drop_if_exists index(:reactions, [:receiver_id])

    drop_if_exists index(:stories, [:headline_id])

    drop_if_exists index(:stories, [:user_id])

    drop_if_exists index(:traits_flags, [:category_id])

    drop_if_exists index(:user_roles, [:role_id])

    drop_if_exists index(:user_roles, [:user_id])

    drop_if_exists index(:users, [:registration_completed_at])

    drop_if_exists index(:users, [:state])

    drop_if_exists index(:users, [:gender])

    drop_if_exists index(:users, [:created_at])

    drop_if_exists index(:users, [:is_private])

    drop_if_exists index(:users, [:zip_code])
  end
end
