Prisma

P

Prisma

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

Join

P3005 Error running Prisma migrate

I am working on a NextJS project that uses prisma. I was able to define my initial schemas and deploy my initial migrations successfully. I made a small change in the diff screenshot attached to this message and I am able to run npx run db push with no issues. When I try to run npx prisma migrate dev to generate a migration, I get the following error: ``` Error: P3005 ...
No description

i want a field to be an array in my mysql schema

I've created my model but in the image field I want it to be an array, so I can insert many images. Is there a solution? generator client { provider = "prisma-client-js" }...

Wierd type error with prisma codegen

29.01 qrtag:build: ./prisma/client/runtime/edge-esm.js:1:1
29.01 qrtag:build: Type error: Declaration emit for this file requires using private name 'i'. An explicit type annotation may unblock declaration emit.
29.01 qrtag:build: ./prisma/client/runtime/edge-esm.js:1:1
29.01 qrtag:build: Type error: Declaration emit for this file requires using private name 'i'. An explicit type annotation may unblock declaration emit.
...

why that not work?

Code: ```ts await prisma.pedOutfitFolder.upsert({ where: { userId: this.db.id, name: 'root' }, update: {},...
No description

Sorting by related field

Hey guys 🙂 I have a relation like: Ingredient(translation: IngredientTranslation[]) -> IngredientTranslation (name, langId.. ) (image 1) Is there a way to sort the ingredients by name? Since i get only _count on the translation field (img 2)...
No description

When to run migrations

Hi! I'm a bit unsure as to when is the best time to run database migrations when deploying new versions of an app, and would love to hear your opinions. Many suggest to run migrations as part of the deploy step during CI/CD, but my concern is that there'll be a window of time where to database has been updated, but the new code hasn't been deployed yet. How do people deal with this? Or do some of you run migrations before starting the web server instead?

Paying for this service but can't login. On multiple accounts now

As the title says. I keep running into these callback errors or whatever this is. I need to access my accelerate dashboard....
No description

Monorepo setup: Prisma with NestJS

I currently have a postgres database that uses row level security. This database is used by two services that are built with NestJS. - auth service - core service ...

Update nested field in composite types

I have a deeply nested structure. It has to be this way. I want to update a single field at the end of the nested tree structure. How do I accomplish this?...

How to use enum?

I'm using Next.js and TypeScript for my project, but I'm getting an error when I attempt to call prisma create. Error: Type 'string' is not assignable to type 'Status | undefined'.ts(2322) ```tsx // page.tsx const [name, setName] = useState('');...

Turbo setup with prisma and pnpm

I have a setup using turborepo and running a few apps and some shared packages together and it works well in dev but i can't figure out how to setup docker, pnpm and prisma together. I've written my dockerfile below and my tree structure is Prisma; /apps/qrtag/prisma/prisma.schema ...

Prisma new field adding will thorw the unkown error

```sql model User { id String @id @default(auto()) @map("_id") @db.ObjectId email String @unique hashedPassword String...

Check constraint migration fails with syntax error

I made the following migration file and ran the migration: ```sql ALTER TABLE "api_owner" ADD CONSTRAINT "check_owner_one_null" CHECK (user_id IS NOT NULL AND organization_id IS NULL) OR (user_id IS NULL AND organization_id IS NOT NULL);...

Optimizing a query

I currently have the following code to update the pricing of the items in the database: ```ts const prismapromises = Object.keys(items).map((item) => prisma.minion.update({ where: { id: item },...

Raw query doesn't work

``js let result: any = await this.prisma.$queryRaw select V.name, V.id, SUM(O."amount"::BIGINT)::BIGINT from "Variety" V left join "Flower" as F on F."varietyId" = V.id...

how to make onDelete: SetNull only work for one field

I have a relation which has 2 fields, one being optional and one is a required field, how do I make my schema so that when the referenced model is deleted it only sets the optional field to null?

Cursor based pagination without numeric id available in table

When using cursor based pagination (https://www.prisma.io/docs/orm/prisma-client/queries/pagination#cursor-based-pagination) what if a table has no sequential number? Imagine a Person table with an id which is a guid, or maybe just in the format 'firstname-lastname' (like 'vivian-defoe'). And then I would like to do cursor based pagination in combination with an user supplied order (like via a REST api users can provide the sorting option like first_name, last_name, gender, date_of_birth, place_name_of_origin. Is that possible, or should I use offset pagination in that case?...

Cloudflare D1 support

Hi, I've searched the server for this and found an answer from Nurul 2 months ago saying this feature is planned. From what I've seen you guys don't like to share ETAs so instead could you just tell me if works on this has been started or not? Thanks! Looking forward to this...

I need to convert find many query to find raw query...

@kapa.ai await this.prisma.incident.findMany({ where: { title: { contains: filter?.title },...