Prisma

P

Prisma

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

Join

Frequent constraint failed on id when using @id @default(autoincrement())

Is there anything I should know about how @id @default(autoincrement()) works? We're using postgresql. We find that if you delete a row and then insert that same row with the same id, we hit a prisma:error Unique constraint failed on the fields: (id)....

Single table inheritance

How to use Single Table Inheritance with prisma ?

Pulse error: Could not reach the specified datasource db url

New Pulse user here (experienced Prisma ORM user). Trying to connect to my local db via connection string: postgresql://postgres:@localhost:5432/my_db?schema=public. At first I received an error that a password is required, so I stopped the server, added a pw of postgres to the database, changed connection string to postgresql://postgres:postgres@localhost:5432/my_db?schema=public, and then restarted the server. But still I continually get the "Could not reach specified db url" error. My NextJS app using the same connection string with Prisma ORM runs just fine, as does DBeaver for accessing the database. But for whatever reason, Pulse cannot connect. Any thoughts? Full error message below. I'm on PostgreSQL 16. I’m super eager to try Pulse, both locally and then ideally in an AWS/RDS production environment. Thanks.
Prisma Pulse could not reach the specified datasource db url. This could be caused by an incorrect datasource URL or database firewall rules, or certificate issues. This is probably not a problem with Prisma Pulse. The network error was: "server did not respond on the specified hostname and port. Proxy request failed."...

Connecting relations misunderstanding

As I understood so far its either you just add foreign key if you want to connect with existing record or into the relation object you add connect, however i got a strange error, the studentId (foreign key) is provided but it still asks me for a student (relation), any ideas why?
No description

Pull Operator not Existing?

```ts await db.$transaction([ db.account.update({ where: { id: values[0],...

Prisma.Decimal is not a Decimal

i am using prisma with postgresql and i got a lot of problems with prisma.decimal. i tried to store it as new Prisma.Decimal(number Input) and when i get it back from Prisma, i get an [object Object] there is no way i can convert this into a Decimal. Every Method -> toNumber() etc. results in a error, that this is not a function. So i tried to do the following Prisma.Decimal.IsDecimal(Object form Database), as u can see the result is false. ...
No description

How to solve this GraphQL mutation error with Prisma ORM & NestJS

I am creating a graphql api using nestjs, prisma. When using the graphql playground to create a user I am getting an error as you can seen in the screenshot below. A row is created only with the id other fields of the user model are not transfered. Please have a look and any guidance would be appreciated. It's been a week I am trying to fix this to no avail.
No description

Does 'asc' sorting order sorts my createdAt timestamps from the oldest to the latest or viceversa?

Hello everyone, I want to sort my MySQL records by the createdAt timestamp, so if I specify the orderBy to be asc, then will it sort the records from the oldest to the latest or vice-versa? Thanks in advance?...

how to create the _prisma_migration table in a specific schema?

I do not have perms on the Public schema due to how the db and its perms are set up. Is there a way to config prisma so that the migrations table will be created in a different schema? For example, under a "prisma" schema or something like that?...

Multiple Prisma clients and connection pooling

I would like to use multiple Prisma clients in my application, basically like so: ```ts const p1 = new PrismaClient({config}) const p2 = new PrismaClient({config})...

Cannot perform I/O on behalf of a different request. I/O objects (such as streams, request/response

I'm running into this issue with Neon, Next-on-pages (Cloudflare) with the new edge (without accelerate) release. I see the documentation here (https://www.prisma.io/docs/orm/prisma-client/deployment/edge/deploy-to-vercel#neon) that says I should setup the prisma client via: ``` const neon = new Pool({ connectionString: process.env.DATABASE_URL }) const adapter = new PrismaNeon(neon)...

Prisma(postgres) stuck at `where: {assets: {none: {}}}`

I understand that the query is tight. But isn't there a way to do it? I have only ~1m records in assets. My goal is to get entity where assetsCount = 0(without raw queries); For example this query works lightning fast. ```...

Data is not showing in table

schema.prisma file. ```js generator client { provider = "prisma-client-js" }...
No description

Multiple datasources

I work with two DB. One is mySQL and the other is MongoDB. Is it possible to connect prisma to both or do I need to do mongo separately and mySQL with prisma? Dont ask why, I´am new and will adapt in the beginning......

Fixing slow query

Hey guys, any idea why this query might suddenly take 9 seconds? ```ts export async function getStatusChecks(urlId: string) { console.time("getStatusChecks");...

backup in prisma

hey, i quickly want to know how we handle backup in prisma

Weird bug in dates

Hello guys im facing a weird bug im using MySQL, the date stored in the db is : 2023-11-08 04:37:53.231 -> readable ( 2023-11-08 04:37:53 ) and if i use prisma to retrive it i get: 2023-11-08T04:37:53.231Z -> readable ( 2023-11-08 06:37:53 ) any idea on why this is happening and what might the problem be and how to fix it? ...
No description

How does Priama handle connection cleanup in the connection pool?

I'm currently looking into the possibility of moving our database to Aurora to take advantage of autoscaled DB capacity. However, I'm imagining there could be potential issues depending on how Prisma handles its connection pool. Specifically: 1) Does Prisma ever close or "refresh" idle connections once established? If it keeps them live forever, I can imagine this could prevent instance scale-in from happening, at least in a reasonable timespan, as eg a read replica would still have connections that its waiting to be terminated (or in the case of serverless v2, there may be more idle connections than can be supported with the allocated compute capacity can support) 2) What happens if the DB itself closes the idle connections, eg if I lowered wait_timeout? Would it just remove the connection from the pool and establish a new connection if needed? If I'm reading the engines source correctly, it appears that there is both a default max lifetime (which may be configurable via an undocumented connection url query parameter?) as well as a periodic health check? Looking at the metrics for my current staging DB instance it doesn't seem to be releasing connections though, even though it gets barely any traffic...

Edge + Accelerate cold start

Is there coldstart with edge + accelerate? it takes like 10 seconds for my query to get a result is this normal? Any way to speed it up?...

Error: @prisma/client did not initialize yet. Please run "prisma generate"

I have several Nextjs v12 projects using Prisma with a remote Postgresql db. Today when trying to deploy I came across this error message for no known reason.
Error: @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.
Error: @prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.
I deploy to a Caprover server using a Dockerfile....