28fecdfaad
- Remove database provider switching logic from prisma.ts and auth.ts - Hardcode PostgreSQL as the only supported database - Remove switch-database.js and use-dev-db.js scripts - Remove Python utility scripts that used sqlite3 directly - Update justfile to remove SQLite test targets - Update package.json to remove db:switch script - Update Dockerfile.ci-base to default to PostgreSQL - Update .env.example to remove SQLite mention - Update playwright.config.ts comments - Update .gitignore to remove SQLite file patterns This eliminates the root cause of test failures: the dev server and test Prisma client were using different databases (PostgreSQL vs SQLite).
22 lines
607 B
TypeScript
22 lines
607 B
TypeScript
import { PrismaClient } from '@prisma/client'
|
|
import { PrismaPg } from '@prisma/adapter-pg'
|
|
|
|
const globalForPrisma = globalThis as unknown as {
|
|
prisma: PrismaClient | undefined
|
|
}
|
|
|
|
const databaseUrl = process.env.DATABASE_URL
|
|
|
|
if (!databaseUrl) {
|
|
throw new Error('DATABASE_URL environment variable is required.')
|
|
}
|
|
|
|
const createPrismaClient = () => {
|
|
const adapter = new PrismaPg({ connectionString: databaseUrl })
|
|
return new PrismaClient({ adapter })
|
|
}
|
|
|
|
export const prisma = globalForPrisma.prisma ?? createPrismaClient()
|
|
|
|
if (process.env.NODE_ENV !== 'production') globalForPrisma.prisma = prisma
|