Prisma

P

Prisma

The official Discord for the Prisma ORM and Prisma Data Platform! Learn more at https://prisma.io

Join

Adding a new relation to models that already have a relation

I had 2 models with an implicit many to many relationship, but now i need a one to many relationship. Below is the diff of the 2 models, but when i try to run the migration prisma migrate dev I get You are about to drop the _ContributorToUgc table, which is not empty (59430 rows).. Is there any way to add the second relation without having to drop the existing relation table from the implicit many to many relationship? ```diff...

prisma enum types as argument type?

i've got this function: ```ts export async function log(arg1) { // logic...
Solution:
turns out because I was using amonorepo I needed to export * from my prisma db file, and import the type from the package

Log Transports

Is it possible to set up transports for Prisma Client logs? Context: I want to push logs to Grafana Loki using its HTTP endpoint. Here's an example of Pino logger doing it: https://www.npmjs.com/package/pino-loki ...

Using Prisma with Supabase and NuxtJS/Nitro

Are there any examples out there?

PrismaClientInitializationError - Medal awarded for whoever that solves this.

Hello boys and girls, and a big thank you for reading this. I have a website created with react nextjs using prisma orm and cockroachDB as Db and hosted in Vercel. In my logs, I sometimes recieve this error below, but when I go to the page, the page works fine each time.
PrismaClientInitializationError: Invalid prisma.product.findMany() invocation: ...

Prisma optimize showing error page

I accidentally performance tested my api with Optimize on and now i see this
No description

findMany where first/latest of 1:n relation meets certain condition

I can't seem to find a solution to this problem: I would like to do a findMany query and get only those entries whose first (latest) relation of many (1:n) meets a condition, eg. a field equals to some value. I'm using latest Prisma with Postgres. Is this not possible? Should I do a rawQuery? Thanks

General question about the free version of Accelerate

Want to test this in a feature environment but unsure about the expectations once we use up the free limit, what happens? Does the service stop working entirely? Or does it route directly to the db connection without the usage of cache / pooling optimization offered by accelerate TLDR: (Once we use up the free limit, does my app break)...

table does not exist in bdd but does exist

in the final packaging of my backend with espress and prisma into using the schema and the sqlite database, both are synchronized but when I try to use my database it tells me that it does not find the table main.Usuario but my table is only called Usuario, maybe this is the error but how do I fix it? ``js PrismaClientKnownRequestError: 0|bundle | Invalid prisma.usuario.findFirst() invocation: 0|bundle | The table main.Usuario` does not exist in the current database....

tabla

in the final packaging of my backend with espress and prisma into using the schema and the sqlite database, both are synchronized but when I try to use my database it tells me that it does not find the table main.Usuario but my table is only called Usuario, maybe this is the error but how do I fix it? ``js PrismaClientKnownRequestError: 0|bundle | Invalid prisma.usuario.findFirst() invocation: 0|bundle | The table main.Usuario` does not exist in the current database....

Hello every one,Add Accelerate to my application with PrismaService class (extend PrismaClient)

Hello every one, I'm having the problem Add Accelerate to my application: PrismaService.ts ...

I have a nested create many query I am getting Unknown argument 'QuestionOptions'

(v5.17.0)CockroachDB , I restarted the application I have removed all migration. I have re-migrated the data again. and push the data. But I'm still having this problem...

Prisma doesn't see .env.development

Hi! I want to seperate my dev and prod env on my NextJS project. NextJS follow this rule by default, next dev use .env.development and next build use .env or .env.production. But Prisma doesn't follow this rule. When I want to migrate/generate prisma-client on my test env, that DB URLs located at .env.development, Prisma always use .env, and tries to connect prod database. My package.json file scripts look like that:...

Solve optimistic concurrency issue without adding a `version` field

Question In the following page there is a suggestion how to solve concurrency issue by adding a version field and ask about it in the where clause when updating a model: ```js...

Finding model constraints in code

Hello, I'm looking for a way to find the foreign keys of a model in the Prisma client. Not by typing but in JS. I can't find anything, even after digging into the engine...

Recursive CTE

Hello all, I'm trying to make a recursive query, but I'm not sure where to start? I have something like the following model: ```js model Role {...
Solution:
I'm not sure I'm too satisfied with the answer, but I ended up writing a view to solve my issue, and then use seed.ts to ensure that it exists.

Is there any way to avoid this cast?

``` public forProject<T extends Prisma.unified_applicationDefaultArgs>( projectId: string, payload?: T, txn: Prisma.TransactionClient = this.prisma...

I have a nested create many query I am getting Unknown argument 'answers'

(v5.16.1) CockroachDB , I restarted the application I have removed all migration. I have re-migrated the data again. and push the data. But I'm still having this problem...
No description

Getting P2023 When getting params

I am getting this error message when getting params with the id: ``` code: 'P2023', clientVersion: '5.17.0', meta: {...
Next