PrismaClientKnownRequestError: Invalid prisma.b2bTransaction.findUnique()

prisma table B2bTransaction exists in database cross-checked with the studio, but when try to use in hono on production, it gives this error:
PrismaClientKnownRequestError: Invalid prisma.b2bTransaction.findUnique() invocation: The table public.B2bTransaction does not exist in the current database.
PrismaClientKnownRequestError: Invalid prisma.b2bTransaction.findUnique() invocation: The table public.B2bTransaction does not exist in the current database.
table schema
model B2bTransaction {
id String @id @default(uuid())
amount Int
timestamp DateTime @default(now())
status TransactionStatus
type TransactionType

webhookId String? @unique // To track webhook processing
webhookStatus WebhookStatus?
webhookAttempts Int @default(0)
lastWebhookAttempt DateTime?

senderUserId String?
receiverUserId String?

senderAccountNumber String?
receiverAccountNumber String?

senderBankName String
receiverBankName String


senderUser User? @relation("SenderBankRelation", fields: [senderUserId], references: [id], onDelete: SetNull)
receiverUser User? @relation("ReceiverBankRelation", fields: [receiverUserId], references: [id], onDelete: SetNull)

@@index([senderUserId])
@@index([receiverUserId])
@@index([webhookId])
}
model B2bTransaction {
id String @id @default(uuid())
amount Int
timestamp DateTime @default(now())
status TransactionStatus
type TransactionType

webhookId String? @unique // To track webhook processing
webhookStatus WebhookStatus?
webhookAttempts Int @default(0)
lastWebhookAttempt DateTime?

senderUserId String?
receiverUserId String?

senderAccountNumber String?
receiverAccountNumber String?

senderBankName String
receiverBankName String


senderUser User? @relation("SenderBankRelation", fields: [senderUserId], references: [id], onDelete: SetNull)
receiverUser User? @relation("ReceiverBankRelation", fields: [receiverUserId], references: [id], onDelete: SetNull)

@@index([senderUserId])
@@index([receiverUserId])
@@index([webhookId])
}
target code:
if (!decryptedData.txnId) {
return { success: false, message: "Transaction ID not found", paymentToken: null };
}

// fetch transaction data
const transaction = await db.b2bTransaction.findUnique({
where: {
id: decryptedData.txnId,
//webhookId: webhookId!
},
select: {
id: true,
senderUserId: true,
receiverUserId: true,
senderBankName: true,
amount: true,
status: true,
webhookStatus: true,
},
});
if (!decryptedData.txnId) {
return { success: false, message: "Transaction ID not found", paymentToken: null };
}

// fetch transaction data
const transaction = await db.b2bTransaction.findUnique({
where: {
id: decryptedData.txnId,
//webhookId: webhookId!
},
select: {
id: true,
senderUserId: true,
receiverUserId: true,
senderBankName: true,
amount: true,
status: true,
webhookStatus: true,
},
});
prisma version: "@prisma/client": "^5.22.0",
5 Replies
Nurul
Nurul2w ago
Is npx prisma generate a part of your deployment script? Did you run npx prisma migrate deploy in your production environment to apply any pending migrations?
~/ Cultured Man
~/ Cultured ManOP2w ago
i am deploying this on hono so i have did all npx prisma generate, db push, db deploy but it still gives this error in production meanwhile in local development it works fine this is a part of turborepo monorepo and i am deploying via wrangler CLI
Nurul
Nurul2w ago
Did you add B2bTransaction table recently, or was it already a part of database before?
Nurul
Nurul2w ago
Also, I see you have submitted a GitHub Issue recently: https://github.com/prisma/prisma/issues/25913
GitHub
PrismaClientKnownRequestError: Invalid `prisma.b2bTransaction.findU...
Bug description prisma table B2bTransaction exists in database cross-checked withthe studio also but when try to use in hono on production gives this error: PrismaClientKnownRequestError: Invalid `...
~/ Cultured Man
~/ Cultured ManOP2w ago
i have 2 table like this b2b and p2p i made both of them together a while back and this is the first time i am using b2b in prod environment. closing this as the issue is resolved. Just wanna say humans can be so stupid sometimes the problem was I have 2 URL's DATABASE_URL and UNPOOLED_DATABASE_URL so what was happening here is the database neon provided by default is there's /neon and I was using a different one for my project and somehow I copied neon's db in DATABASE_URL and UNPOOLED_DATABASE_URL is using my correct URL. but locally I have 2 envs and the one which I am using locally for all shared packages has the correct URL but my .dev.vars got the wrong one which was propagating to Cloudflare. Thanks

Did you find this page helpful?