feat: Nutzerverwaltung + CMDB + Wissensdatenbank (Grundgeruest)

This commit is contained in:
mscadm 2026-07-13 15:28:52 +00:00
parent 99a9761901
commit b802d252ba
1 changed files with 47 additions and 0 deletions

View File

@ -83,3 +83,50 @@ CREATE INDEX IF NOT EXISTS idx_timeline_ticket ON ticket_timeline (ticket_id);
CREATE INDEX IF NOT EXISTS idx_audit_tenant_zeit ON audit_log (tenant_id, zeit DESC); CREATE INDEX IF NOT EXISTS idx_audit_tenant_zeit ON audit_log (tenant_id, zeit DESC);
CREATE INDEX IF NOT EXISTS idx_services_tenant ON services (tenant_id); CREATE INDEX IF NOT EXISTS idx_services_tenant ON services (tenant_id);
CREATE INDEX IF NOT EXISTS idx_users_tenant ON users (tenant_id); CREATE INDEX IF NOT EXISTS idx_users_tenant ON users (tenant_id);
-- Vorbereitung fuer spaetere AD/LDAP-Anbindung (Nutzer-Vorgabe 2026-07-13):
-- 'local' = im ITSM selbst verwaltetes Konto (heutiger Stand), 'ldap' reserviert
-- fuer die kommende Ausbaustufe. Kein Verhaltensunterschied heute, nur Vorbereitung.
ALTER TABLE users ADD COLUMN IF NOT EXISTS auth_source TEXT NOT NULL DEFAULT 'local';
-- ── Wissensdatenbank ──────────────────────────────────────────────────────────
CREATE TABLE IF NOT EXISTS kb_articles (
id SERIAL PRIMARY KEY,
tenant_id INTEGER NOT NULL REFERENCES tenants(id) ON DELETE CASCADE,
titel TEXT NOT NULL,
kategorie TEXT NOT NULL DEFAULT 'Allgemein',
inhalt TEXT NOT NULL,
tags TEXT,
autor_user_id INTEGER REFERENCES users(id) ON DELETE SET NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS idx_kb_tenant_kategorie ON kb_articles (tenant_id, kategorie);
-- ── CMDB (Configuration Management Database) ──────────────────────────────────
CREATE TABLE IF NOT EXISTS configuration_items (
id SERIAL PRIMARY KEY,
tenant_id INTEGER NOT NULL REFERENCES tenants(id) ON DELETE CASCADE,
name TEXT NOT NULL,
ci_typ TEXT NOT NULL DEFAULT 'Sonstiges',
status TEXT NOT NULL DEFAULT 'Aktiv',
beschreibung TEXT,
attribute JSONB NOT NULL DEFAULT '{}'::jsonb,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS idx_ci_tenant_typ ON configuration_items (tenant_id, ci_typ);
CREATE INDEX IF NOT EXISTS idx_ci_tenant_status ON configuration_items (tenant_id, status);
CREATE TABLE IF NOT EXISTS ci_relationships (
id SERIAL PRIMARY KEY,
tenant_id INTEGER NOT NULL REFERENCES tenants(id) ON DELETE CASCADE,
from_ci_id INTEGER NOT NULL REFERENCES configuration_items(id) ON DELETE CASCADE,
to_ci_id INTEGER NOT NULL REFERENCES configuration_items(id) ON DELETE CASCADE,
beziehungs_typ TEXT NOT NULL DEFAULT 'haengt ab von',
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS idx_cirel_tenant ON ci_relationships (tenant_id);
CREATE INDEX IF NOT EXISTS idx_cirel_from ON ci_relationships (from_ci_id);
CREATE INDEX IF NOT EXISTS idx_cirel_to ON ci_relationships (to_ci_id);