defmodule GitGud.Repo.Migrations.AddRunnerRegTokenExpiry do
use Ecto.Migration
# A repository's or organization's runner registration token used to be
# good forever and for any number of runners. Now it expires
# (`GitGud.Workflows.Runners`, 24h by default) and registers one runner.
# A token minted before this gets a day from the migration rather than
# stopping on the spot.
def up do
for table <- [:repositories, :organizations] do
alter table(table) do
add :runner_reg_token_expires_at, :utc_datetime
end
end
flush()
for table <- ~w(repositories organizations) do
execute """
UPDATE #{table}
SET runner_reg_token_expires_at = date_trunc('second', now() AT TIME ZONE 'utc') + interval '1 day'
WHERE runner_reg_token_hash IS NOT NULL
"""
end
end
def down do
for table <- [:repositories, :organizations] do
alter table(table) do
remove :runner_reg_token_expires_at
end
end
end
end
neiam
/gitgud
Git Gud
public · Issues · Pulls · Labels · Forks · Compare · Actions success · Badges · Packages
⭐
1
Log in to mark this repository.
1011 B · text
History
b868907