Prisma

P

Prisma

The official Discord server of Prisma! Find us online at prisma.io

Join

How to use migrate when having a directurl and normal url

I get this error Please make sure your database server is running at db.caowreskbcgzoajwwjvy.supabase.co:5432.

How to create project?

When hitting the New Project button on the dash, the Create project button in the dialog is disabled. How can I create a new project?
No description

Error: Cannot fetch data from service:getaddrinfo ENOTFOUND aws-us-east-1.prisma-data.com

Any idea why we'd be getting this error? The database connection seems to be working for us otherwise, but seeing this error in a few places in our logs

Mongodb schema update - how to

I looked at the documentation to understand the right way to update the schema for MongoDB. I'm doing prisma generate prima db push ...

I created free postgresql database in Aiven.io. But I can't connect database with Prisma.

I created new database in Aiven.io for free. This database connected with pgAmin4. But I can't connect with prisma. Please help me....

Inserting data with migration file

Is there a way to insert data to a table that has foreign keys? I get an error: Error: P3006 ...

Migrate dev failing in a project it used to work in. Says issue w/ user defined functions.

Hi there, I'm trying to update my schema, it hasn't been touched in this project for about a year and a half. when i run prisma migrate dev --name add_rbac_tables --create-only i get this error: ...

Prisma Optimize does not show queries

I've installed the extension, it shows the prompt in my terminal, but the web UI does not show queries.
No description

Help With 2 database usage in same api

hey guys what's up? i have a project running with postgresql, but in the same application i also have to run mysql on some occasions. I have already configured the connections and everything is ok. my question is, is there any way in the CLI to avoid having to put --schema=./prisma/schema-postgresql.prisma at the end when executing any command? I'm thinking something like yarn prisma generate --mysql...

cacheStrategy is never

error :
Type '{ ttl: number; swr: number; }' is not assignable to type 'never'.ts(2322)
(property) cacheStrategy: never
Type '{ ttl: number; swr: number; }' is not assignable to type 'never'.ts(2322)
(property) cacheStrategy: never
...
Solution:
okey is good all work i have conflict ( DATABASE_URL x2 in .env )

Unique Constraints Failed

When adding a record with prisma studio, I am getting the error "Unique constraint failed on the constraint: `Server_secret_key`". I don't have any field named "Server_secret_key" so I don't know why its saying that.

Representing a User with sub-roles

Hello, I'm trying to figure out the best way to represent this relationship. I know union types aren't possible in the schema but I can define them in the sdl. I'm not sure a union is what I want though, because it adds complexity to the queries. Essentially I have a user. I don't do a lot of business logic in my app with that user though, instead I use other models like "Staff" and "Customer". A user could be a staff OR a customer. During the user creation process I connect either the staff or customer model. However that leads to one being empty and my app having to probe whether a user is staff or customer. I'm currently doing something like this (reason being staff and customer are very different, so this scales better): ```...

Relations issue

how do I write relations that have multiple columns that are related to one entity
No description

Prisma Accelerate - Nextjs Middleware - NextAuth V5 - EDGE_FUNCTION_INVOCATION_TIMEOUT

Hi everyone, I am working on upgrading my implementation of NextAuth to the latest version V5 to improve edge compatibility. Everything is working in my development environment but once deployed to Vercel I am receiving EDGE_FUNCTION_INVOCATION_TIMEOUT in about 20% of my edge middleware requests.
This is using Prisma Accelerate which based on the V5 documentation *should * be compatible. There in an open ticket under the next-auth repo where others had ran into similar issues with various ORM's but based on the comments it seemed it was related to the client initialization and/or edge compatibility. I added a comment (https://github.com/nextauthjs/next-auth/issues/10773#issuecomment-2198257896) with my package.json, Prisma Client initialization including the accelerate extension, and my middleware. Just wanted to see if anyone had successfully implemented Prisma Accelerate + NextAuth V5 + Auth Middleware. I enabled all logging on my Prisma Client but nothing really jumped out as suspicious, in the successful middleware requests I see the succesful POST to accelerate.prisma, in the failed middleware requests, there are no outgoing requests so I am not sure if this points to the client initialization issues?...

Unknown argument 'ID' in double nested find many with one to many relation

Hi I have been recently refactoring a bunch of my more complicated queries to no longer use query raw unsafe and I have ran into an issue I have been unable to find any resources on. Any help would be greatly appreciated I will post more details as I cant fit everything into the post....

How do you organize your Prisma.validator schemas?

I have a bunch of predefined select and include schemas. Where do I put them in my project? I need some inspiration. ```typescript export function getUserDataSelect(loggedInUserId: string) { return Prisma.validator<Prisma.UserSelect>()({...

Get P6004 and P5000 error running Vercel production query through Accelerate

I receive this error and I don't understand the cause is. The query is straightforward, performing a fetch of 25 rows with a JOIN, no filtering or sorting, that should reply fast with a small handful of columns to populate a MUI DataGridPro React component. This works via Preview and localhost. Accelerate status appears fine today, but not sure about Cloudflare. I hope someone can give me a clue or how to more quickly debug this and get me on track to resolve ASAP. I'm not sure why this is timing out. ``PrismaClientKnownRequestError: Invalid prisma.$queryRawUnsafe()` invocation: This request could not be understood by the server: {"type":"UnknownJsonError","body":{"code":"P6004","message":"The Query did not produce a result within the maximum allowed execution time of 10 seconds."}} (The request id was: 89b23bb50aecb477) at In.handleRequestError (/var/task/node_modules/.prisma/client/runtime/library.js:122:6877)...

nested transactions

Hey, i got something like -> prisma.transaction(async prisma => { test(1) test(2) ...

Prisma for expo app

Please need help setting up prisma for expo app, i followed the instructions on the github page but keep geeting error meesage. ERROR Error: 🟥 @prisma/react-native failed to initialize, js engine:
hermes. i need step by step setup. thanks...

Invalidating/flushing cache in Accelerate

We're using Accelerate but haven't started using the caching mechanism. From reading the docs, I'm not seeing any obvious way to flush/invalidate cache on the fly. We have some slow queries which we would like to cache, but these queries are used in report generation, so we would want to be able to refresh the cache when new data has been added which changes the report data. What is the recommended approach for achieving this with Prisma Accelerate?