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:
parent
60393e40b1
commit
cce0f25419
10 changed files with 1433 additions and 6 deletions
17
lib/prisma.ts
Normal file
17
lib/prisma.ts
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import { PrismaClient } from '@prisma/client'
|
||||
import { PrismaPg } from '@prisma/adapter-pg'
|
||||
|
||||
function createPrismaClient() {
|
||||
const connectionString = process.env.DATABASE_URL
|
||||
if (!connectionString) {
|
||||
throw new Error('DATABASE_URL environment variable is required')
|
||||
}
|
||||
const adapter = new PrismaPg({ connectionString })
|
||||
return new PrismaClient({ adapter })
|
||||
}
|
||||
|
||||
const globalForPrisma = globalThis as unknown as { prisma: PrismaClient }
|
||||
|
||||
export const prisma = globalForPrisma.prisma ?? createPrismaClient()
|
||||
|
||||
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma
|
||||
Loading…
Add table
Add a link
Reference in a new issue