From 14d3e6ae5ba02be65b7e83322936427d7150224a Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Sun, 19 Apr 2026 17:26:53 -0500 Subject: [PATCH] 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. --- .../20260419222624_add_kind_to_grid_tasks.exs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 priv/repo/migrations/20260419222624_add_kind_to_grid_tasks.exs diff --git a/priv/repo/migrations/20260419222624_add_kind_to_grid_tasks.exs b/priv/repo/migrations/20260419222624_add_kind_to_grid_tasks.exs new file mode 100644 index 00000000..8de82280 --- /dev/null +++ b/priv/repo/migrations/20260419222624_add_kind_to_grid_tasks.exs @@ -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