 
     alter table(:teams) do
       add :disqualified_at, :utc_datetime, default: nil
-      add :disqualified_by, fk(:users), default: nil
+      add :disqualified_by_id, fk(:users), default: nil
       add :eligible, :boolean, default: false
       add :prize_preference_hmac_secret, :string
       add :tie_breaker, :integer

  import Ecto.Query

  alias Api.{Crypto, Repo, User, Team, Category}

  defp fk(table, on_delete \\ :nilify_all, type \\ :uuid) do
    references(table, on_delete: on_delete, type: type)

    |> Enum.map(fn
      {team, tie_breaker} ->
        team
        |> Changeset.change(
          prize_preference_hmac_secret: Crypto.random_hmac(),
          tie_breaker: tie_breaker
        )
        |> Repo.update!
    end)

