defmodule GitGud.Repo.Migrations.AddRunnerAgentLabels do
use Ecto.Migration
@moduledoc """
Split `runners.labels` into two columns:
* `labels` — operator-assigned. Source of truth for which
jobs the runner picks up. Set via the
offline-mint UI / mix task; never touched by
the runner's `Declare` RPC.
* `agent_labels` — runner-self-reported. The runner tells us what
it can do on every `Declare`; we record but
don't use for routing. Surfaced in the UI for
operator visibility.
Before this split, `Declare` overwrote `labels` with whatever the
runner sent, which silently invalidated operator intent on the next
runner restart.
Backfill: copy existing `labels` to `agent_labels` so prior runners
keep their (admittedly self-reported) labels until an operator
re-mints. Same JSONB shape: `%{"labels" => [...]}`.
"""
def up do
alter table(:runners) do
add :agent_labels, :map, default: %{"labels" => []}
end
execute "UPDATE runners SET agent_labels = labels"
end
def down do
alter table(:runners) do
remove :agent_labels
end
end
end
1.2 KiB · text
5af55d9