towerops/priv/repo/migrations/20260109184838_create_agent_tokens.exs

25 lines
790 B
Elixir

defmodule Towerops.Repo.Migrations.CreateAgentTokens do
use Ecto.Migration
def change do
create table(:agent_tokens, primary_key: false) do
add :id, :binary_id, primary_key: true
add :token_hash, :binary, null: false
add :name, :string, null: false
add :last_seen_at, :utc_datetime
add :last_ip, :string
add :enabled, :boolean, default: true, null: false
add :metadata, :map, default: %{}, null: false
add :organization_id,
references(:organizations, type: :binary_id, on_delete: :delete_all),
null: false
timestamps(type: :utc_datetime)
end
create index(:agent_tokens, [:token_hash])
create index(:agent_tokens, [:organization_id])
create index(:agent_tokens, [:last_seen_at])
end
end