Files
DataStack/prisma/schema.prisma
T
2026-10-25 06:12:47 -07:00

81 lines
2.2 KiB
Plaintext

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
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 {
id String @id @default(cuid())
clientId String @unique
name String
secret String
rateLimit Int @default(100) // Max events per second
status String @default("active") // active | revoked
totalEvents BigInt @default(0)
lastActive DateTime?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
apiKeys ApiKey[]
@@map("client_sdks")
}
model ApiKey {
id String @id @default(cuid())
clientId String
client ClientSDK @relation(fields: [clientId], references: [clientId], onDelete: Cascade)
keyHash String
expiresAt DateTime?
createdAt DateTime @default(now())
@@map("api_keys")
}
model AdminUser {
id Int @id @default(1) @db.SmallInt
email String @unique
passwordSalt Bytes @map("password_salt")
passwordHash Bytes @map("password_hash")
createdAt DateTime @default(now()) @map("created_at")
@@map("admin_users")
}
model AdminSettings {
id String @id @default("default")
serverPort Int @default(4000)
webPort Int @default(3000)
maxEventsPerSec Int @default(100)
maxPayloadSizeKb Int @default(100)
batchFlushThreshold Int @default(500)
batchFlushIntervalMs Int @default(2000)
fileRotationMb Int @default(100)
jwtSecret String
enableIdempotency Boolean @default(true)
autoPruneDays Int @default(30)
updatedAt DateTime @updatedAt
@@map("admin_settings")
}
model AuditLog {
id String @id @default(cuid())
action String
actor String
details String? // JSON string
ipAddress String?
createdAt DateTime @default(now())
@@map("audit_logs")
}