Deploying the t3-App on Vercel

I'm having a t3-app with the database hosted on planetscale and the app on vercel. Everything works well on the dev server but I cant make the connection to the db once I deploy it to vercel. I have mysql as my provider, and relationMode set to prisma. I have added the env variables on the .env file and on vercel dashboard. However once I deploy it to vercel I'm getting this error on the web console.
8 Replies
Neto
Neto3y ago
Can you show the Prisma file?
Tony
TonyOP3y ago
import { PrismaClient } from "@prisma/client";

import { env } from "../../env/server.mjs";

declare global {
// eslint-disable-next-line no-var
var prisma: PrismaClient | undefined;
}

export const prisma =
global.prisma ||
new PrismaClient({
log:
env.NODE_ENV === "development" ? ["query", "error", "warn"] : ["error"],
});

if (env.NODE_ENV !== "production") {
global.prisma = prisma;
}
import { PrismaClient } from "@prisma/client";

import { env } from "../../env/server.mjs";

declare global {
// eslint-disable-next-line no-var
var prisma: PrismaClient | undefined;
}

export const prisma =
global.prisma ||
new PrismaClient({
log:
env.NODE_ENV === "development" ? ["query", "error", "warn"] : ["error"],
});

if (env.NODE_ENV !== "production") {
global.prisma = prisma;
}
If you mean the file where I export prisma client, or you meant the schema ?
Neto
Neto3y ago
schema file
Tony
TonyOP3y ago
generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "mysql"
url = env("DATABASE_URL")
relationMode = "prisma"
}

model Articles {
id String @id @default(cuid()) @db.VarChar(255)
title String @db.VarChar(255)
description String @db.VarChar(255)
imageUrl String @db.VarChar(255)
externalUrl String @db.VarChar(255)
}
generator client {
provider = "prisma-client-js"
}

datasource db {
provider = "mysql"
url = env("DATABASE_URL")
relationMode = "prisma"
}

model Articles {
id String @id @default(cuid()) @db.VarChar(255)
title String @db.VarChar(255)
description String @db.VarChar(255)
imageUrl String @db.VarChar(255)
externalUrl String @db.VarChar(255)
}
here it is
Neto
Neto3y ago
check the env url on vercel
Tony
TonyOP3y ago
strange enough the env variables are correct, I even added the planetscale integration on vercel so that it imports them correctly
nexxel
nexxel3y ago
@Tony___ you haven't done npx prisma db push you did it when the provider was sqlite (the default for create-t3-app) once you change your schema always run npx prisma db push then it will work
Tony
TonyOP3y ago
yeah that worked Thanks mate

Did you find this page helpful?