23 lines
1008 B
MySQL
23 lines
1008 B
MySQL
|
|
-- AP1.7c — Actor Service Tokens für Operational API (Vibe-Coder / Agenten)
|
||
|
|
|
||
|
|
CREATE TABLE actor_service_tokens (
|
||
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
||
|
|
tenant_id UUID NOT NULL REFERENCES tenants(id) ON DELETE CASCADE,
|
||
|
|
actor_id UUID NOT NULL REFERENCES actors(id) ON DELETE CASCADE,
|
||
|
|
label VARCHAR(255) NOT NULL,
|
||
|
|
token_prefix VARCHAR(16) NOT NULL,
|
||
|
|
token_hash VARCHAR(64) NOT NULL,
|
||
|
|
capabilities JSONB NOT NULL DEFAULT '[]'::jsonb,
|
||
|
|
is_active BOOLEAN NOT NULL DEFAULT TRUE,
|
||
|
|
expires_at TIMESTAMPTZ NULL,
|
||
|
|
last_used_at TIMESTAMPTZ NULL,
|
||
|
|
created_by_user_id UUID NULL REFERENCES users(id) ON DELETE SET NULL,
|
||
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||
|
|
revoked_at TIMESTAMPTZ NULL,
|
||
|
|
UNIQUE (token_prefix)
|
||
|
|
);
|
||
|
|
|
||
|
|
CREATE INDEX idx_actor_service_tokens_tenant ON actor_service_tokens(tenant_id);
|
||
|
|
CREATE INDEX idx_actor_service_tokens_actor ON actor_service_tokens(actor_id);
|
||
|
|
CREATE INDEX idx_actor_service_tokens_hash ON actor_service_tokens(token_hash);
|