- Truncate accumulated stdout/stderr to last 64KB before persisting FlowStep to prevent unbounded DB growth on verbose commands - Add @@index([user_id, started_at(sort: Desc)]) to FlowRun schema so audit list queries (WHERE user_id = ? ORDER BY started_at DESC) use the index - Add migration 20260513200000_flowrun_user_idx Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
61 lines
1.4 KiB
Text
61 lines
1.4 KiB
Text
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
}
|
|
|
|
enum FlowStatus {
|
|
pending
|
|
running
|
|
success
|
|
failed
|
|
cancelled
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(cuid())
|
|
email String @unique
|
|
pwd_hash String
|
|
created_at DateTime @default(now())
|
|
sessions Session[]
|
|
flow_runs FlowRun[]
|
|
}
|
|
|
|
model Session {
|
|
id String @id @default(cuid())
|
|
user_id String
|
|
token_hash String @unique
|
|
expires_at DateTime
|
|
user User @relation(fields: [user_id], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
model FlowRun {
|
|
id String @id @default(cuid())
|
|
user_id String
|
|
flow_key String
|
|
status FlowStatus @default(pending)
|
|
dry_run Boolean @default(false)
|
|
started_at DateTime @default(now())
|
|
ended_at DateTime?
|
|
exit_code Int?
|
|
user User @relation(fields: [user_id], references: [id], onDelete: Cascade)
|
|
steps FlowStep[]
|
|
|
|
@@index([user_id, started_at(sort: Desc)])
|
|
}
|
|
|
|
model FlowStep {
|
|
id String @id @default(cuid())
|
|
flow_run_id String
|
|
step_index Int
|
|
command_key String
|
|
args_json String?
|
|
stdout String?
|
|
stderr String?
|
|
exit_code Int?
|
|
started_at DateTime @default(now())
|
|
ended_at DateTime?
|
|
flow_run FlowRun @relation(fields: [flow_run_id], references: [id], onDelete: Cascade)
|
|
}
|