feat: Prisma schema, migrations en seed voor auth en audit-log

- Models: User, Session, FlowRun, FlowStep met FlowStatus enum
- prisma.config.ts met DATABASE_URL via @prisma/adapter-pg (Prisma 7 API)
- Initiële migratie applied op ops_dashboard database
- Seed-script voor 1 user via SEED_USER_EMAIL/SEED_USER_PASSWORD env-vars
- lib/prisma.ts als gedeelde singleton client voor Next.js

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Scrum4Me Agent 2026-05-13 17:04:27 +02:00
parent 60393e40b1
commit cce0f25419
10 changed files with 1433 additions and 6 deletions

59
prisma/schema.prisma Normal file
View file

@ -0,0 +1,59 @@
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[]
}
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)
}