Prisma

P

Prisma

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

Join

Dynamic select column doesn't return the correct type

Hello, I have an issue with a particular query I'm trying to run. I have a relation model called 'Posts' and in this particular query I only want to include posts if a specific condition is met before hand (i.e. condition ? { /* select */ } : false). When doing this the return type changes, seek below result. ```ts const user = await this.prismaService.users.findFirst({ select: {...

Schema Troubleshooting

Hi everyone reposting this, i have a pretty simple Schema with three models. However, whenever i try to push the schema to my MYSQL DB, i keep running into foreign key restraints. I don't see anything wrong with my relations thats causing this to occur. One thing to note is that i did accidentally migrate the schema to my db, but i went and dropped the table and the migration folder. Did I make a silly syntax mistake that i'm missing, or will i need to baseline my db due to migrations being out...
No description

Relations on non unique fields

Hi guys, i'm building a new db and i need it to be multilingual. in order to achieve that i've created a contents table wich will handle every text/image for each language ```prisma model Contents { id Int language Languages...

Upgrade from 6.0.1 -> 6.5.0 broke migrate dev

I recently upgraded from 6.0.1 to 6.5.0, and didn't change any migrations or schema files. But when I run migrate reset and then run migrate dev I am now receiving an exit code of 130 whereas previously I could generate migrations without issue. This happens regardless of if I modify a schema file or not. The output of the command looks like this: ``` Drift detected: Your database schema is not in sync with your migration history....

Prisma PostgresProvisioning stuck?

Hello. Im quite new to prisma, but when I set up a new environment, it just states "Provisioning" and under setup "Almost there! Your database will be ready shortly."Anyone that knows what can cause this? I have 6 environments available in my plan, so that should not be the issue. Thanks!...

Prisma Client could not locate the Query Engine for runtime "rhel-openssl-3.0.x"

Hello. I have been using Prisma for years and love it. However, I am having an issue with a new project when deploying to vercel. It's seems this is a fairly common issue, as there is an entire github post about it here:https://github.com/prisma/prisma/discussions/19498. In the last two weeks, it seems 3-4 other people have had the same issue, yet none of these have been responded to. I was wondering if there is a known solution/if this is currently being worked on?

Module build failed: UnhandledSchemeError: Reading from "node:async_hooks" is not handled by plugins

I'm on a Next.js 14 app and just switched from 6.5.0 to 6.6.0, but now I'm seeing the error Module build failed: UnhandledSchemeError: Reading from "node:async_hooks" is not handled by plugins (Unhandled scheme). Webpack supports "data:" and "file:" URIs by default. You may need an additional plugin to handle "node:" URIs....

Migrating from MongoDB to PostgreSQL: How to handle embedded types/objects?

I'm an intermediate developer working with Next.js, Node.js, and React. I'm currently using Prisma with MongoDB for my project, but I'm considering migrating to PostgreSQL. One of my biggest challenges is figuring out how to handle embedded types/objects that I use extensively in my MongoDB schema. For example, I have structures like: ```typescript...

How to make a library/package that expects a Prisma client with a certain schema?

Hi, I'm currently trying to make it so I have my Prisma Schema as a private GitHub package that I can consume in various environments and projects, using the new prisma-client generator, which expects an output path. I have my package called @blabla/prisma-client, which exports all Prisma types from the generated client (e.g ./generated/client), after having been built with tsc, to output .d.ts files, which are all I really care about, to use in different projects. I import that package into my modules which accept a Prisma Client on initialization, to use its types, and then I export my functions and classes for consumption in a different project....
No description

prisma@6.6.0 type error when prismaClient generated at specific folder with "cjs" module type

@Prisma @Prisma AI Help I've been trying to use prisma v6.6.0 with nestjs app and generated to cjs module format but I kept getting type error at runtime...

Running "prisma db push" leads to migration failure

It works if I run yarn prisma db push for the first time on a new database. Run that again, I get error: ``` Error: ERROR: type "TriggerType" already exists 0: sql_schema_connector::apply_migration::migration_step...

Synchronous functions

I need to query a DB from a synchronous function. Unfortunately making it async isn't possible because it implements an interface that I can't touch. I also can't just ignore the promise because the said sync function actually processes the data returned from the query. Is there any solution?

Help with queryRawUnsafe

Hey all, I have a query that previously worked that started to fail. Based off documentation, this is expected since the column names are dynamically generated when using query raw. Can I get help on converting it to a queryRawUnsafe? Here is a sampe query of what I am trying to convert:...

Prisma Schema not updating / working

I have created this schema for users ```js model users { id Int @id @default(autoincrement()) username String? @db.VarChar(255)...

Runtime Error on latest versions of Next, AuthJS, and Prisma when initializing prisma adapter

I'm running the most recent versions of everything (just building from scratch) as soon as I enable the prisma adapter in AuthJS I get a runtime error: I am running with Prisma Postgres which should be Edge compatible Error: Failed to load external module node:module: ReferenceError: Cannot access 'require' before initialization...

Hi Prisma Team 👋We're currently using a Prisma Accelerate database and ran into a critical issue.

Due to a misconfigured migration script, we accidentally deleted production data while trying to migrate to a new DB instance. Would it be possible to recover a backup from April 20, 2024 (or any time before April 21)? This is really important as the data loss has impacted our client. ...

Mysql Migration for prod via docker and github action (CI/CD)

hello sir, i am trying to deplogy my express app on production via github action to aws EC2 so when everver i am pushing or merging into prod i want to run the github pipeline and docker file which will deploy my express app on ec2 so what do i change in my docker file and github workflow file
...
No description

How can I perform batch updates unique entities in Prisma?

How can I perform batch updates in Prisma — akin to createMany — by passing an array or collection to a single operation? I’m working inside long-lived interactive transactions and need to update multiple records by their unique IDs. What’s the best approach? 1. Using Promise.all([ tx.model.update(…)*N ]) for each item 2. Writing a custom extension or helper with an SQL builder 3. Executing raw SQL via tx.$executeRaw...

Prisma generate with Turborepo never prompting for name

After following the instructions to setup Prisma with turborepo, when runnning pnpm turbo db:migrate, the terminal just hangs and never enters the interactive CLI. I have made sure to set the command as persistent ``` "db:migrate": {...

transferring project to another workspace

hey, am i able to transfer a project to another workspace i own?