-
Notifications
You must be signed in to change notification settings - Fork 19
Closed
Labels
Description
I'm working on getting CloudFflare d1 support for Prisma with Nuxt Hub, I've created this issue to help track my progress, so far this version of server/utils/prisma.ts is working for me.
import { PrismaD1 } from '@prisma/adapter-d1'
import { PrismaClient } from '@prisma/client'
import type { D1Database } from '@nuxthub/core'
import type { EventHandlerRequest, H3Event } from 'h3'
import models from '../models/index'
export function useDB(event: H3Event<EventHandlerRequest>): D1Database {
return event.context.cloudflare.env.DB as D1Database
}
let prismaClient: PrismaClient
export function usePrisma(event: H3Event<EventHandlerRequest>) {
if (!prismaClient) {
const adapter = new PrismaD1(useDB(event))
prismaClient = new PrismaClient({ adapter })
}
return prismaClient
}My current challenge is how to run local migrations:
- Cannot use
npx prisma migratebecause it doesn't harness the d1 driver - Cannot use
wranglerbecause it goes after the .sqlite files in.wranglerand not.data
Any suggestions/tips/etc would be appreciated, I'll update this issue as I progress
Reactions are currently unavailable