feat(audit): 增加审计事件基础模块
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
CREATE TABLE "audit_events" (
|
||||
"id" TEXT NOT NULL,
|
||||
"actor_id" TEXT,
|
||||
"actor_name" TEXT NOT NULL DEFAULT '',
|
||||
"action" TEXT NOT NULL,
|
||||
"entity_type" TEXT NOT NULL,
|
||||
"entity_id" TEXT NOT NULL,
|
||||
"product_id" TEXT,
|
||||
"project_id" TEXT,
|
||||
"version_id" TEXT,
|
||||
"scope" JSONB NOT NULL DEFAULT '{}',
|
||||
"before" JSONB,
|
||||
"after" JSONB,
|
||||
"metadata" JSONB NOT NULL DEFAULT '{}',
|
||||
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
CONSTRAINT "audit_events_pkey" PRIMARY KEY ("id", "created_at")
|
||||
) PARTITION BY RANGE ("created_at");
|
||||
|
||||
CREATE TABLE "audit_events_default" PARTITION OF "audit_events" DEFAULT;
|
||||
CREATE INDEX "audit_events_actor_created_at_idx" ON "audit_events"("actor_id", "created_at" DESC);
|
||||
CREATE INDEX "audit_events_entity_created_at_idx" ON "audit_events"("entity_type", "entity_id", "created_at" DESC);
|
||||
CREATE INDEX "audit_events_product_created_at_idx" ON "audit_events"("product_id", "created_at" DESC);
|
||||
CREATE INDEX "audit_events_project_created_at_idx" ON "audit_events"("project_id", "created_at" DESC);
|
||||
CREATE INDEX "audit_events_version_created_at_idx" ON "audit_events"("version_id", "created_at" DESC);
|
||||
@@ -423,6 +423,26 @@ model AiLog {
|
||||
@@map("ai_logs")
|
||||
}
|
||||
|
||||
model AuditEvent {
|
||||
id String @default(cuid())
|
||||
actorId String? @map("actor_id")
|
||||
actorName String @default("") @map("actor_name")
|
||||
action String
|
||||
entityType String @map("entity_type")
|
||||
entityId String @map("entity_id")
|
||||
productId String? @map("product_id")
|
||||
projectId String? @map("project_id")
|
||||
versionId String? @map("version_id")
|
||||
scope Json @default("{}")
|
||||
before Json?
|
||||
after Json?
|
||||
metadata Json @default("{}")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
|
||||
@@id([id, createdAt])
|
||||
@@map("audit_events")
|
||||
}
|
||||
|
||||
model XiaobaoRiskSummary {
|
||||
versionId String @id @map("version_id")
|
||||
riskLevel String @map("risk_level")
|
||||
|
||||
Reference in New Issue
Block a user