diff --git a/elixir/apps/domain/priv/repo/manual_migrations/20250622165802_index_auth_providers_on_adapter.exs b/elixir/apps/domain/priv/repo/manual_migrations/20250622165802_index_auth_providers_on_adapter.exs new file mode 100644 index 000000000..0afa74497 --- /dev/null +++ b/elixir/apps/domain/priv/repo/manual_migrations/20250622165802_index_auth_providers_on_adapter.exs @@ -0,0 +1,22 @@ +defmodule Domain.Repo.Migrations.IndexAuthProvidersOnAdapter do + use Ecto.Migration + + @disable_ddl_transaction true + + def up do + # Used for refresh access token job which uses a cross-account query, + # so account_id is intentionally not included in the index. + create_if_not_exists( + index( + :auth_providers, + [:adapter], + where: "disabled_at IS NULL AND deleted_at IS NULL", + name: :index_auth_providers_on_adapter + ) + ) + end + + def down do + drop_if_exists(index(:auth_providers, [:adapter], name: :index_auth_providers_on_adapter)) + end +end