Ajoute la base organisable par carnet (schéma, champs partagés, valeurs par note) avec activation guidée, tableau éditable, kanban et suppression de colonnes. Corrige le multiselect en vue tableau et enrichit sidebar, grille et i18n FR/EN. Inclut aussi les améliorations flashcards SM-2, l'audit consentement IA et la robustesse du serveur MCP (config, validation, rate-limit, métriques). Co-authored-by: Cursor <cursoragent@cursor.com>
37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
import { PrismaClient } from '@prisma/client'
|
|
|
|
const prismaClientSingleton = () => {
|
|
return new PrismaClient({
|
|
datasources: {
|
|
db: {
|
|
url: process.env.DATABASE_URL,
|
|
},
|
|
},
|
|
})
|
|
}
|
|
|
|
/** Dev hot-reload can keep an old PrismaClient missing newly generated models. */
|
|
function needsFreshPrismaClient(client: PrismaClient | undefined): boolean {
|
|
if (!client) return true
|
|
return typeof (client as PrismaClient & { flashcard?: unknown }).flashcard === 'undefined'
|
|
}
|
|
|
|
declare const globalThis: {
|
|
prismaGlobal: ReturnType<typeof prismaClientSingleton>;
|
|
} & typeof global;
|
|
|
|
let prisma = globalThis.prismaGlobal ?? prismaClientSingleton()
|
|
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
if (needsFreshPrismaClient(globalThis.prismaGlobal)) {
|
|
prisma = prismaClientSingleton()
|
|
}
|
|
globalThis.prismaGlobal = prisma
|
|
|
|
const models = Object.keys(prisma).filter(k => !k.startsWith('_') && !k.startsWith('$'))
|
|
console.log('[Prisma] Models loaded:', models.join(', '))
|
|
}
|
|
|
|
export { prisma }
|
|
export default prisma
|