Prisma

P

Prisma

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

Join

Typescript clutter: Prisma + Postgresql + JSON fields is a mess

Guys all my code is cluttered with typecasting Prisma.JsonValue Prisma.JsonObject Prisma.JsonNullValueInput...

Prisma + Turborepo build fails in Vercel

I have a turborepo with prisma as a package , when running locally everything works, even builds locally too, but when I am deploying the project it throws an error stating DATABASE_URL is not present: Environment variable not found: DATABASE_URL....

How can i string filter but for number?

Hey im still new to prisma and basically i want this getId Method to work: `async test(id) this.prisma.idTable.findMany({ where: {...

Unique constraint fails when creating user(s)in parallel during tests for api endpoints

When I run tests in my app in parallel that have helpers that create users in the DB, i get this error: ``` FAIL ../test/cartridge.test.ts > /api/cartridge > post /api/cartridge - create a cartridge PrismaClientKnownRequestError:...

[SOLVED] Prisma won't build consistently with the same Dockerfile specs

Hi, when bundling an app with Prisma, it works on a node:20 and node:20-alpine locally. When building with the same machines on Github Action ubuntu-latest runner they fail with the following error:
PrismaClientValidationError: Invalid client engine type, please use `library` or `binary`
PrismaClientValidationError: Invalid client engine type, please use `library` or `binary`
...
Solution:
Solved: Missing NEXUS_STANDALONE environment variable in "base as build" Docker execution context. Rationale: in my local machine, the environment variable was available at a higher reference point....

Ordering by a nullable relation

Hello everyone, so I have the following schema: ```...

Error: P3005 The database schema is not empty.

I want to initialize prisma in an existing supabase project. All schemas in datasource db.schemas are empty, and public._prisma_migrations does not exist. I have the initial migration in migrations/0_init/migration.sql, generated via https://www.prisma.io/docs/orm/prisma-migrate/workflows/baselining I'm getting Error: P3005 The database schema is not empty. with either prisma migrate dev and prisma migrate deploy. In addition prisma migrate reset also has the same error. ...

Eloquent's relations equivalent in Prisma?

While it doesn't make a big difference in DX, Eloquen's relations do save some time and make it fun to type those short DSL queries. I haven't skimmed through the whole doc of Prisma, but is there an equivalent to what I described?...

db push stuck

hello! when running prisma db push it logs that the schema is loaded then logs the datasource then does nothing! what do I do?
Solution:
It happened to me some time ago, then I realized that the database port in the connection URL was incorrect. Try to check it.

Image storing

Hi everyone, I just want to know what is the best way to store images according to these info about the system I'm building. - a user needs to have a profile picture. - I need to store a number of images for each user. - a user can create a post, and the post may have an image. - The hero section of the app may have a dynamic image that the admin can change....

Introspecting an existing database doesn't handle join tables correctly

I'm in the process of adding Prisma to an existing project with a large existing database (originally created with Prisma 1). I've introspected the database and edited the schema so that the names of the relation fields are cased correctly. I then created an initial migration SQL file as per the guide and marked it as applied. When I try to create a new migration, I keep getting errors telling me that ALL of my existing JOIN tables are incorrect: ``` Drift detected: Your database schema is not in sync with your migration history. ...

Troubles with prisma when deploying to fly.io

Im just finish my backend built with Bun, Elysia and Prisma and im about to deploy it on fly.io, but when i try to start my server i get the error of the image and my VM is shutdowned
No description

Prisma keeps generating same migrations

Hmm, I am having some weird issue with my "Invoice" model.. whenever I generate a migration, it keeps adding these lines to the migrations, over and over... What could be the cause of this? ``SQL -- AlterTable ALTER TABLE Invoice MODIFY amountTotal DOUBLE NOT NULL DEFAULT (round(amountSubtotal + amountTax`, 2)),...
Solution:
Solution: After using prisma db pull I saw that the database returned these formulas without spaces, so I had to change those values in the prisma schema and now it seems to be okay 🙂
No description

Native types for enums

Hi, I would like to add a native type to an enum field. Like that : ``` enum Role { USER...

prisma db push doesnt update the database

im getting no output + theres nothing in the db
No description

First time migration!

I'm workin on a project that's in production on a few servers (not all are in my control). I want to add migrations to this project, and I'm wondering about 'Applying the initial migrations'. Is the idea that I run this npx prisma migrate resolve --applied 0_init in all of my production databases, or is this for the local one when I create the migration?...
No description

SQLite with Prisma problems

Hello! I have app hosted on my VPS, its using Prisma with SQLite (before migrating to Postgres) but im getting some problems. When im trying to do operations after scraping (its using Puppeteer so its consuming a lot of resources on my VPS) and after scrapping process im trying to save data in DB, then im often getting these errors (On the screenshot). After reload apps with pm2 everything is ok. What may be issue? Its because i have too weak VPS (2core, 2gb Ram + 4gb swapped) or its just SQLite thing and Postgres should handle that? If you need any more informations to help, please, tell me Thanks 🙏...
No description

Why does no-body even react to my tiny bugfix? Is it wrong?

I created a super tiny bugfix for an issue with the types in one of the packages, but nobody even gave any feedback in nearly a month - I don't understand why. https://github.com/prisma/prisma/pull/24916...

Prisma type generating doesn't work in Docker

Hi, I'm trying to build docker container for my node.js application but all the time it fails because when I try to build the application, it gives me errors saying that @prisma/client types are undefined. I'd be glad if someone helped me, I'm stuck with this. Dockerfile: ``` FROM node:18-alpine...