[React Native] Creating client with Supabase crashes

with db.ts like so (pretty basic)
import { PrismaClient } from '@prisma/client/react-native'
import '@prisma/react-native'

export const db = new PrismaClient({
log: ['error'],
})

export async function initializeDb() {
try {
db.$applyPendingMigrations()
console.log('migrations complete')
} catch (e) {
console.error(`failed to apply migrations: ${e}`)
throw new Error('Applying migrations failed, your app is now in an inconsistent state. We cannot guarantee safety, it is now your responsibility to reset the database or tell the user to re-install the app')
}
}
import { PrismaClient } from '@prisma/client/react-native'
import '@prisma/react-native'

export const db = new PrismaClient({
log: ['error'],
})

export async function initializeDb() {
try {
db.$applyPendingMigrations()
console.log('migrations complete')
} catch (e) {
console.error(`failed to apply migrations: ${e}`)
throw new Error('Applying migrations failed, your app is now in an inconsistent state. We cannot guarantee safety, it is now your responsibility to reset the database or tell the user to re-install the app')
}
}
the app crashes after calling this function
useEffect(() => {
async function init() {
await initializeDb() // <-
}
init()
}, [])
useEffect(() => {
async function init() {
await initializeDb() // <-
}
init()
}, [])
with the following schema
generator client {
provider = "prisma-client-js"
previewFeatures = ["reactNative", "driverAdapters"]
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
directUrl = env("DIRECT_URL")
}

model User {
id Int @id @default(autoincrement())
username String
}
generator client {
provider = "prisma-client-js"
previewFeatures = ["reactNative", "driverAdapters"]
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
directUrl = env("DIRECT_URL")
}

model User {
id Int @id @default(autoincrement())
username String
}
4 Replies
piscopancer
piscopancerOP2mo ago
piscopancer
piscopancerOP2mo ago
i cannot see logs because of how fast it crashes I also did prebuilds and removed cache performed migration + generation before prebuild makes me think SQLite is the only supported DB type
RaphaelEtim
RaphaelEtim2mo ago
Prisma for React Native in Early access only has support for SQLite at the moment.
piscopancer
piscopancerOP2mo ago
thanks does it mean that you are planning on adding more dbs in the future for rn prisma? also how long do you think it will take your team to make it compatible with Turso (sqlite) and other services like supabase or vercel db, long story short make it as compatible as regular Prisma?
Want results from more Discord servers?
Add your server