feat(grid_tasks): add kind column to split forecast vs analysis work

Prep for Stream A of Phase 3 rust migration: f00's native-duct merge,
NEXRAD, and commercial-link enrichment move to Rust via the same
grid_tasks work queue. kind='analysis' (single row per run) vs
kind='forecast' (18 rows per run) lets one Rust worker dispatch on
payload type without a second table.

Forecast default keeps existing Rust claim_next behaviour unchanged
during cutover.
This commit is contained in:
Graham McIntire 2026-04-19 17:26:53 -05:00
parent ed6b16dc60
commit 14d3e6ae5b
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59

View file

@ -0,0 +1,24 @@
defmodule Microwaveprop.Repo.Migrations.AddKindToGridTasks do
use Ecto.Migration
# `kind` splits the queue between forecast-hour work (the 18 f01..f18 rows
# Rust has owned since Phase 2) and analysis-hour work (f00, which Elixir
# still runs because it carries the native-level duct merge, NEXRAD, and
# commercial-link enrichment). Stream A of the Phase 3 migration plan
# ports those enrichments to Rust and flips f00 onto this queue too.
# Forecast rows default to 'forecast' so existing producers keep working
# during the transition.
def change do
alter table(:grid_tasks) do
add :kind, :string, null: false, default: "forecast"
end
create index(:grid_tasks, [:status, :kind])
# Replace (run_time, forecast_hour) uniqueness with a three-column key so
# an analysis row and a forecast row for f00 can coexist during the
# cutover. Post-cutover the analysis row replaces f00 outright.
drop_if_exists unique_index(:grid_tasks, [:run_time, :forecast_hour])
create unique_index(:grid_tasks, [:run_time, :forecast_hour, :kind])
end
end