priv/repo/migrations/20260823071500_allow_deployments_write_api_token_scope.exs

58e6347eeb72 · 612 B

defmodule OpenAgents.Repo.Migrations.AllowDeploymentsWriteApiTokenScope do
  use Ecto.Migration

  def up do
    drop constraint(:api_tokens, :api_tokens_scopes_allowed)

    create constraint(:api_tokens, :api_tokens_scopes_allowed,
             check:
               "scopes <@ ARRAY['chat:account', 'forge:write', 'deployments:write']::varchar[]"
           )
  end

  def down do
    drop constraint(:api_tokens, :api_tokens_scopes_allowed)

    create constraint(:api_tokens, :api_tokens_scopes_allowed,
             check: "scopes <@ ARRAY['chat:account', 'forge:write']::varchar[]"
           )
  end
end