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

  def change do
    # Covering index for the map viewport query:
    # SELECT lat, lon, score WHERE band_mhz = X AND valid_time = Y
    #   AND lat BETWEEN a AND b AND lon BETWEEN c AND d
    # INCLUDE (score) avoids heap lookups — index-only scan
    create index(:propagation_scores, [:band_mhz, :valid_time, :lat, :lon],
             include: [:score],
             name: :propagation_scores_viewport_idx
           )
  end
end
