defmodule Microwaveprop.Repo.Migrations.AddPointForecastIndex do
  use Ecto.Migration

  def change do
    # Covers point_forecast query: WHERE band_mhz AND lat AND lon ORDER BY valid_time
    # INCLUDE score for index-only scan
    create index(:propagation_scores, [:band_mhz, :lat, :lon, :valid_time],
             include: [:score],
             name: :propagation_scores_point_forecast_idx
           )

    # Covers available_valid_times query: WHERE band_mhz SELECT DISTINCT valid_time
    # Already covered by propagation_scores_band_mhz_valid_time_index, but adding
    # the prune query: DELETE WHERE valid_time < cutoff (covered by valid_time_index)
  end
end
