feat: ST-001–ST-005 foundation — scaffolding, Prisma, schema, seed, env
- ST-001: Next.js 16 + React 19 + TypeScript strict + Tailwind + shadcn/ui + all deps - ST-002: Prisma v7 setup with better-sqlite3 adapter (local) and pg adapter (cloud) - ST-003: Full schema migration (users, pbis, stories, sprints, tasks, todos, api_tokens) - ST-004: Seed with 9 PBIs, ~40 stories, demo user (demo/demo1234), lars user - ST-005: Zod-validated env vars, .env.example, lib/session, lib/auth, lib/api-auth Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
4cf5833c1d
commit
7f94bb6359
32 changed files with 8653 additions and 183 deletions
32
lib/prisma.ts
Normal file
32
lib/prisma.ts
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import { PrismaClient } from '@prisma/client'
|
||||
|
||||
function createPrismaClient() {
|
||||
const url = process.env.DATABASE_URL
|
||||
if (!url) throw new Error('DATABASE_URL is not set')
|
||||
|
||||
if (url.startsWith('file:')) {
|
||||
// SQLite (local development) — use better-sqlite3 adapter
|
||||
const { PrismaBetterSqlite3 } = require('@prisma/adapter-better-sqlite3')
|
||||
const adapter = new PrismaBetterSqlite3({ url })
|
||||
return new PrismaClient({
|
||||
adapter,
|
||||
log: process.env.NODE_ENV === 'development' ? ['error', 'warn'] : ['error'],
|
||||
})
|
||||
}
|
||||
|
||||
// PostgreSQL (production) — use pg adapter
|
||||
const { Pool } = require('pg')
|
||||
const { PrismaPg } = require('@prisma/adapter-pg')
|
||||
const pool = new Pool({ connectionString: url })
|
||||
const adapter = new PrismaPg(pool)
|
||||
return new PrismaClient({
|
||||
adapter,
|
||||
log: process.env.NODE_ENV === 'development' ? ['error', 'warn'] : ['error'],
|
||||
})
|
||||
}
|
||||
|
||||
const globalForPrisma = globalThis as unknown as { prisma: PrismaClient | undefined }
|
||||
|
||||
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