defmodule GitGud.Repo.Migrations.AddRunnerUuid do
use Ecto.Migration
def change do
# Forgejo runner v12+ validates that the `uuid` field returned from
# the Register call is a real UUID string. We were stringifying the
# integer id, which fails parsing on the runner side. Store a
# generated v4 UUID per runner instead.
alter table(:runners) do
add :uuid, :uuid
end
create unique_index(:runners, [:uuid])
# Backfill existing rows with random UUIDs.
execute(
"UPDATE runners SET uuid = gen_random_uuid() WHERE uuid IS NULL",
"SELECT 1"
)
# Now make it non-null going forward.
alter table(:runners) do
modify :uuid, :uuid, null: false
end
end
end
732 B · text
5af55d9