Managed Git (one Gitea instance per customer, INF-GIT-{CLD,OPR}-{STD,BUS,ENT})
is provisioned by hand; the registry now keeps the record so the portal can
show it under "Verwaltete Infrastruktur" and staff can maintain it.
- 0012_managed_services: table with kind/status checks, UNIQUE (tenant_id,
kind, url), FK cascade on tenant delete (mirrored in the memory store).
- GET /v1/tenants/{id}/managed-services: tenant view without instance_id and
notes; user tokens need IT_ADMIN, OWNER or CXO (else FORBIDDEN_ROLE).
- GET/POST /v1/admin/tenants/{id}/managed-services and PATCH/DELETE
.../{sid}: staff view and maintenance, validation codes invalid_kind,
invalid_name, invalid_url, invalid_sku, invalid_status,
invalid_instance_id, invalid_notes; 409 duplicate.
- Audit managed_service.created/updated/deleted with the staff actor;
updated carries the changed fields and old/new status.
- OpenAPI spec and tests.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
22 lines
1.1 KiB
SQL
22 lines
1.1 KiB
SQL
-- Managed services (portal#77): infrastructure BreakPilot runs for a tenant,
|
|
-- for now Managed Git (one Gitea instance per customer, SKUs
|
|
-- INF-GIT-{CLD,OPR}-{STD,BUS,ENT}). Provisioned by hand (v0); staff keep the
|
|
-- record in the admin area and the portal shows it under "Verwaltete
|
|
-- Infrastruktur". instance_id and notes are staff-only.
|
|
CREATE TABLE managed_services (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
tenant_id UUID NOT NULL REFERENCES tenants(id) ON DELETE CASCADE,
|
|
kind TEXT NOT NULL CHECK (kind IN ('git')),
|
|
name TEXT NOT NULL,
|
|
url TEXT NOT NULL,
|
|
sku TEXT NOT NULL,
|
|
status TEXT NOT NULL DEFAULT 'provisioning'
|
|
CHECK (status IN ('provisioning', 'active', 'restricted', 'halted')),
|
|
instance_id TEXT NOT NULL DEFAULT '',
|
|
notes TEXT NOT NULL DEFAULT '',
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
|
UNIQUE (tenant_id, kind, url)
|
|
);
|
|
CREATE INDEX managed_services_tenant ON managed_services (tenant_id);
|