feat(knowledge): add scoped activity audit trail

This commit is contained in:
wizardchen
2026-07-22 19:15:27 +08:00
committed by lyingbug
parent f195e0494c
commit a3a0308b62
44 changed files with 2429 additions and 81 deletions
@@ -0,0 +1,5 @@
DROP INDEX IF EXISTS idx_audit_logs_tenant_scope_desc;
ALTER TABLE audit_logs
DROP COLUMN IF EXISTS scope_id,
DROP COLUMN IF EXISTS scope_type;
@@ -0,0 +1,8 @@
-- Add a generic parent scope to audit rows so one immutable audit stream can
-- project resource-specific activity feeds without one log table per feature.
ALTER TABLE audit_logs
ADD COLUMN IF NOT EXISTS scope_type VARCHAR(32) NOT NULL DEFAULT '',
ADD COLUMN IF NOT EXISTS scope_id VARCHAR(64) NOT NULL DEFAULT '';
CREATE INDEX IF NOT EXISTS idx_audit_logs_tenant_scope_desc
ON audit_logs (tenant_id, scope_type, scope_id, id DESC);