Add idempotent migration to ensure precip_1h_in and wx_codes columns exist, then reset weather_queued flag and clear stale observations so the cron re-fetches with precipitation data included.
17 lines
594 B
Elixir
17 lines
594 B
Elixir
defmodule Microwaveprop.Repo.Migrations.BackfillSurfaceObservationsWithPrecipitation do
|
|
use Ecto.Migration
|
|
|
|
def up do
|
|
# Delete surface observations that were fetched without precipitation data
|
|
# so the weather cron re-fetches them with the new p01i/wxcodes fields
|
|
execute "DELETE FROM surface_observations WHERE precip_1h_in IS NULL AND wx_codes IS NULL"
|
|
|
|
# Reset the weather_queued flag so QSOs are re-enqueued for weather fetching
|
|
execute "UPDATE qsos SET weather_queued = false"
|
|
end
|
|
|
|
def down do
|
|
# Cannot restore deleted observations; no-op
|
|
:ok
|
|
end
|
|
end
|