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

  def change do
    alter table(:qsos) do
      add :weather_queued, :boolean, default: false, null: false
    end

    # Backfill existing rows — they were already processed by the import script
    execute "UPDATE qsos SET weather_queued = true", "SELECT 1"

    # Partial index for fast lookup of unprocessed QSOs
    create index(:qsos, [:weather_queued], where: "weather_queued = false")
  end
end
