defmodule Aprsme.Repo.Migrations.AddHasWeatherReceivedAtIndex do
  use Ecto.Migration
  @disable_ddl_transaction true
  @disable_migration_lock true

  def up do
    execute """
    CREATE INDEX IF NOT EXISTS idx_packets_has_weather_time
    ON packets (has_weather, received_at DESC)
    WHERE has_weather = true
    """
  end

  def down do
    execute "DROP INDEX IF EXISTS idx_packets_has_weather_time"
  end
end
