defmodule Towerops.Repo.Migrations.ChangeAgentTokenToPlaintext do
  use Ecto.Migration

  def change do
    # Drop existing tokens since we can't migrate hashed tokens to plaintext
    execute "DELETE FROM agent_tokens", "DELETE FROM agent_tokens"

    # Rename column and change type
    alter table(:agent_tokens) do
      remove :token_hash
      add :token, :text, null: false
    end
  end
end
