defmodule Orcasite.Repo.Migrations.AddIndexesToMetaColumns 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 index(:subscriptions, ["meta"], using: "gin")

    alter table(:subscriptions) do
      modify :meta, :map, default: %{}
    end

    create index(:subscribers, ["meta"], using: "gin")

    alter table(:subscribers) do
      modify :meta, :map, default: %{}
    end

    create index(:notifications, ["meta"], using: "gin")

    alter table(:notifications) do
      modify :meta, :map, default: %{}
    end
  end

  def down do
    alter table(:notifications) do
      modify :meta, :map, default: nil
    end

    drop_if_exists index(:notifications, ["meta"], name: "notifications_meta_index")

    alter table(:subscribers) do
      modify :meta, :map, default: nil
    end

    drop_if_exists index(:subscribers, ["meta"], name: "subscribers_meta_index")

    alter table(:subscriptions) do
      modify :meta, :map, default: nil
    end

    drop_if_exists index(:subscriptions, ["meta"], name: "subscriptions_meta_index")
  end
end