Prisma

P

Prisma

Join the community to ask questions about Prisma and get answers from other members.

Join

Foreign key constraint failed on the field: `anime_season_fkey (index)`

Getting this error when I try to create a new db entry in prisma, no clue why. Using Postgres rismaClientKnownRequestError: Invalid prisma.anime.create() invocation: ...
No description

Delete Prisma Models

Models.py deosn't have the added migration even though its in the migrations folder and was applied to database, how do I just re-gen models.py

can i pass a model to a type, the same way i pass a type to a model in prisma schema ?

i have a one to one relation in prisma schema and i want to switch it with a type instead of creating a new model, but currently i don't know if i can feed the type something other then string number ...
Solution:
Unfortunately this isn’t directly possible in the ORM. We have some suggestions: https://www.prisma.io/docs/orm/prisma-schema/data-model/table-inheritance

Pass current user id to Postgres

In our application we've added a trigger that logs changes to tables. As part of the logs we want to store the id of the user who did the change, and the function that's executed by the trigger gets this by calling current_setting('app.current_user_id', true). Hence the logic on the DB side expects the current user id to be passed using this setting app.current_user_id. On the application side of things we want to pass the user id for all queries. We can do this using a client extension that sets the user id when a query is being ran against the DB (Postgres). However this is a bit impractical as the PrismaClient should only be instantiated once in the application for management of the connection pool, and not once per unique user using the application. How can we make Prisma pass the app.current_user_id setting to Postgres, whilst still keeping Prisma managing the connection pool in a good way?...

Prisma migrate deploy fails in GitHub actions

We have an application that uses Prisma for the ORM and migrations Every time we do prisma migrate deploy to our production schema the migrations fail and gives us an error: ``` Environment variables loaded from .env...

Prisma Accelerate: ConnectorError. SUPABASE

[2024-05-21T05:34:31.404Z] GET http://localhost:3001/api/banners Error fetching Banners: Invalid prisma.banner.findMany() invocation: Error occurred during query execution:...

nested incuding

by some specific reason i should to take data in table by pattern now i have this query ` const resources = await this.prismaService.resource.findMany({...

Running a typescript migration script

I wonder if there's an easy way to run typescript scripts as a migration with Prisma as well. Some of data I need to migrate is related to crypto and don't even know if sql would allow me to derive addresses and this kinda of stuff

Prisma generate just load scheme and then no output

Helo, does anyone know what is happening? I try to npx prisma generate scheme, but there is no error, no output and it ends like in the picture. Tried many node versions and prisma version nothing seems to help. Thanks for any advice!...

how to return an empty array instead of null

I have such a type: ``` type P { id String m Int[]...

Unique index w/ nullable field in unique query

I'm having an issue with a unique index where one of the fields is a nullable field (deleted at) When attempting to findUnique or upsert with the unique index, I'm unable to use it with the value of null (which should get me the only row that's not deleted if there's one). Instead, it errors, saying that the value must not be null and must be a proper date I'm not really sure how to go around this, since I can't separate the where clause to name and deletedAt since I'm required to use unique field(s)...

Question about explicit many to many table

super noob question. i'm using the python client and have the following table setup: model annotators { id Int @id @default(autoincrement()) username String @unique @db.VarChar(150)...
Solution:
👋 we don’t support the python client. That’s a community managed project. I think their GitHub repo has info for their Discord

ts error in library file

When running my project with prisma locally on my pc it works fine but as soon as i try to build my project in docker it fails due to errors with in the prisma type file aparently this is my schema.prisma file https://github.com/Jarco-dev/ferox-statistics/blob/master/prisma/schema.prisma https://i.jarco.dev/4Hw6iHXW.png...
Solution:
Latest version of Prisma requires TS 4.7+

Unable to run the seed script successfully

The seed script ```typescript import { db } from '@/app/lib/database'; import * as data from '@/app/lib/placeholder-data'; ...

Prisma.validator with arguments

Is this the correct way to use Prisma validator (to reuse parts of a query) if the query depends on dynamic data? ```typescript export function getPostDataInclude(loggedInUserId: string | undefined) { return Prisma.validator<Prisma.PostInclude>()({...

Should I stick with raw SQL?

I'm migrating an on old PHP app I wrote 11 years ago to React (Nestjs / Nextjs). In the new stack I'm using Prisma for new calls but I have an old SQL statement I know works. Should I stick with sending it as raw SQL or is there a better way with Prisma? `` const columns = e.date_test_completed AS 'CompletedDate', c.name AS 'courtName', c.number AS 'courtId', COUNT(*) AS 'count', SUM(c.court_fee) AS 'Fee'; const query = SELECT ${columns}...

$on

Hello, im trying to create a connection and catch the erros in a single point using $on, but im getting and error : Argument of type 'string' is not assignable to parameter of type 'never'. Anyone know why?...

Prisma migrations working with more than one container

(English is not my native language, I hope this is understandable.) Hello everyone, I would like to point out that I am new to prisma and am exploring the first complexities in the projects I have been working on. I'm migrating a monolith project to microservices using Nest.js and Docker, and following the prism documentation, I have the history of my migrations in the migration folder. My question is, how can I make all the services have the database synchronized, since they all consume the sam...

Data Location Security

Hi! My company is looking to subscribe to pulse / accelerate but we have data requirements around data location. Is there anywhere that talks about data storage / transient data passthroughs? IE, the data flow through X country or caching is with X company...

The response size of the query exceeded the the maximum of 5MB

Hi prisma team, Since I've set up Accelerate, some queries won't work because of the 5mb limitation. Strangely, the limitation is activated for a small query fetching approx 300 records, whereas it's working fine for far bigger queries. here's the model: model User {...