Files
sp/apps/web/prisma/schema.prisma
Semih b9709ed07e feat(phase3): worker container + event bus + scheduled jobs
apps/worker:
- BullMQ nightly scheduler (cron 0 3 * * *)
- Redis Streams consumer-group per wired/active project
- Persists events to Event model

schema:
- Event model (streamId unique, project + type indexed)
2026-05-13 11:03:58 +00:00

113 lines
2.8 KiB
Plaintext

generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL_PANEL")
}
model User {
id String @id
name String
email String @unique
emailVerified Boolean @default(false)
image String?
twoFactorEnabled Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
sessions Session[]
accounts Account[]
twoFactors TwoFactor[]
}
model Session {
id String @id
userId String
token String @unique
expiresAt DateTime
ipAddress String?
userAgent String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
}
model Account {
id String @id
userId String
accountId String
providerId String
accessToken String?
refreshToken String?
accessTokenExpiresAt DateTime?
refreshTokenExpiresAt DateTime?
scope String?
idToken String?
password String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
}
model Verification {
id String @id
identifier String
value String
expiresAt DateTime
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model TwoFactor {
id String @id
userId String
secret String
backupCodes String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
}
model Project {
id String @id @default(cuid())
key String @unique
name String
description String?
/// planned | wired | active
status String @default("planned")
active Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Event {
id String @id @default(cuid())
streamId String @unique
projectKey String
eventType String
version Int @default(1)
payload Json
occurredAt DateTime
receivedAt DateTime @default(now())
@@index([projectKey, occurredAt])
@@index([eventType])
}
model AuditLog {
id String @id @default(cuid())
actorUserId String?
projectKey String?
endpoint String
method String
requestHash String?
responseStatus Int?
durationMs Int?
sourceIp String?
userAgent String?
createdAt DateTime @default(now())
@@index([createdAt])
@@index([actorUserId])
@@index([projectKey])
}