defmodule Microwaveprop.Repo.Migrations.AddSourceToGridTasks do use Ecto.Migration # `source` splits grid_tasks between HRRR-derived (CONUS) and HRDPS- # derived (Canada) work. Rust workers branch on this column to pick the # right URL pattern + decoder. Default 'hrrr' so existing rows keep # their meaning; HRDPS rows arrive only once HrdpsGridWorker is added # to the cron (deferred until the Rust HRDPS branch ships). def change do alter table(:grid_tasks) do add :source, :string, null: false, default: "hrrr" end # Replace (run_time, forecast_hour, kind) uniqueness with a 4-column # key so HRRR and HRDPS analysis/forecast rows for the same cycle can # coexist. The index also speeds up `claim_next` filters. drop_if_exists unique_index(:grid_tasks, [:run_time, :forecast_hour, :kind]) create unique_index(:grid_tasks, [:run_time, :forecast_hour, :kind, :source]) create index(:grid_tasks, [:source]) end end