// REFERENCE SCHEMA ONLY — NOT EXECUTED BY PRISMA CLI AT RUNTIME. // Canonical PostgreSQL runtime DDL is owned by `core/Database/database.ts` (Port 3000 via `pg`) // and mirrored 1:1 in `server/index.js` (Port 4000 standalone container). // Keep all 5 models below strictly synchronized with `core/Database/database.ts` (verified by tests). generator client { provider = "prisma-client-js" } datasource db { provider = "postgresql" url = env("DATABASE_URL") } // CRITICAL: PostgreSQL is ONLY for Admin / Config / SDK Registration — NOT for collected data. // All collected data is strictly written to CSV files in /storage/data/{clientId}/{YYYY-MM-DD}.csv model ClientSDK { clientId String @id @map("client_id") name String secret String token String rateLimit Int @default(100) @map("rate_limit") // Max events per second status String @default("active") // active | revoked totalEvents BigInt @default(0) @map("total_events") lastActive DateTime? @map("last_active") @db.Timestamptz(6) createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6) updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6) @@map("client_sdks") } model DeletedClient { clientId String @id @map("client_id") deletedAt DateTime @default(now()) @map("deleted_at") @db.Timestamptz(6) @@map("deleted_clients") } model AdminUser { id Int @id @default(1) @db.SmallInt email String @unique passwordSalt Bytes @map("password_salt") passwordHash Bytes @map("password_hash") tokenVersion Int @default(1) @map("token_version") createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz(6) @@map("admin_users") } model AdminLoginAttempt { keyHash String @id @map("key_hash") windowStartedAt DateTime @map("window_started_at") @db.Timestamptz(6) failedAttempts Int @map("failed_attempts") blockedUntil DateTime? @map("blocked_until") @db.Timestamptz(6) updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6) @@map("admin_login_attempts") } model AdminSettings { id String @id @default("default") serverPort Int @default(4000) @map("server_port") webPort Int @default(3000) @map("web_port") maxEventsPerSec Int @default(100) @map("max_events_per_sec") maxPayloadSizeKb Int @default(100) @map("max_payload_size_kb") batchFlushThreshold Int @default(500) @map("batch_flush_threshold") batchFlushIntervalMs Int @default(2000) @map("batch_flush_interval_ms") fileRotationMb Int @default(100) @map("file_rotation_mb") jwtSecret String @map("jwt_secret") enableIdempotency Boolean @default(true) @map("enable_idempotency") autoPruneDays Int @default(30) @map("auto_prune_days") updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6) @@map("admin_settings") }