Prisma

P

Prisma

The official Discord for the Prisma ORM and Prisma Data Platform! Learn more at https://prisma.io

Join

Selecting random records from table

Hi! I would like to ask more experienced people for advice/ideas on how to use prisma to get random records from a table that meet some condition. I believe that fetching all the data from the table and then selecting random records is unnecessary and suboptimal. If anyone has an idea or knows how to achieve such an effect using prism, I would be grateful. 😄

Order by `rowid`?

Is it possible to order by (SQLite) rowid? I need to order by rowid as my table has no other natural sorting column. ```...

Drift detected but no changes in schema

Drift detected: Your database schema is not in sync with your migration history. The following is a summary of the differences between the expected database schema given your migrations files, and the actual schema of the database. `It should be understood as the set of changes to get from the expected schema to the actual schema....

Adding arguments to rawQueryTyped with MySql

The docs mention that you can add arguments to rawQueryTyped queries https://www.prisma.io/docs/orm/prisma-client/using-raw-sql/typedsql#passing-arguments-to-typedsql-queries
SELECT id, name, age
FROM users
WHERE age > ? AND age < ?
SELECT id, name, age
FROM users
WHERE age > ? AND age < ?
...

Bad error messages with array of transactions

I'm concatenating my transactions like this ```
if (!isNil(changes.systems)) transactions = transactions.concat(this.handleSystemChanges(changes.systems, lastPulledAt));...

Search text with Prisma

Hello, guys! I am trying to create a search functionality with prisma and want to ask which is the better way: making it with the search prop or making it with contains prop. Now I am using search and it looks like this ```js function formatSearchQuery(query: string | null): string | undefined {...

Migrating database from sqlserver to postgresql

Hello all, I'm currently tasked with migrating our database schema from the sqlserver provider to postgresql. Not only that, the underlying database has new tables which weren't originally part of the database. If I run the db pull command it generates the schema as it should. The original schema has model names and column names in PascalCase. The new underlying postgresql database and subsequently, the schema is using all lowercase naming conventions. Is there a way to successfully modify the newly generated schema to allow using the newly created prisma client with the old PascalCase naming conventions? I'm aware of the @map && @@map functions but not quite sure if those are needed because the new postgres db has non case sensitive tables/columns....

Upgrade prisma 2 to 5 and got renamed index error

Hi! I recently upgrade prisma 2 to 5. and tried to prisma migrate dev and got this message. Here is message and prisma shema. - schema.prisma `model Tag {...

Row Level Security Example

I'm playing with this example on client extension and row-level-security (RLS). The thing that's got me confused is the example gets a user just by grabbing the first item
const user = await prisma.$extends(bypassRLS()).user.findFirstOrThrow();
const user = await prisma.$extends(bypassRLS()).user.findFirstOrThrow();
I'm using next-auth and I can't figure out how to get the signed-in user from here. Any suggestions? ...

Prisma Transactions stops working once you extend the client with Pulse, Optimize or Accelerate

See title. This stops me from migrating to these products and use in production. Once you extend the client and need to make a Prisma Transaction it will return an error and the transaction fails: TypeError: parentTracer.getSpanLimits is not a function...

Can't set api key/token when using Optimize

The documentation says to add the apikey as follows ```ts import { PrismaClient } from "@prisma/client"; import { withOptimize } from "@prisma/extension-optimize"; ...
No description

Optimize is not showing queries

I've been trying to get optimize to work since it first launched in beta, but queries just don't show up in the dashboard. i'm not sure how to get more logging......

Safe Rolling Deployments When Dropping Columns

Hello, I'm wondering if there are tricks or advice to drop columns safely in production w/ rolling deployments. Here's some context to explain the problem and what I mean by rolling deploys: * dev adds column X to table A in PR-1 * column X is picked up automatically included in Prisma queries on table A like... prisma.client.tableA.findMany({ where: id }) * PR-1 is deployed to PRD and column X is added as a prequisite to rolling out the new version...

Advisory lock errors in CI suddenly ocurring very frequently

I have a newish (about 2 months old) next.js app with prisma deployed on Vercel. Lately I'm getting Error: P1002 on about 75% of my builds, even when there are minutes between builds.
Context: Timed out trying to acquire a postgres advisory lock (SELECT pg_advisory_lock(72707369)). Elapsed: 10000ms. See https://pris.ly/d/migrate-advisory-locking for details.
Context: Timed out trying to acquire a postgres advisory lock (SELECT pg_advisory_lock(72707369)). Elapsed: 10000ms. See https://pris.ly/d/migrate-advisory-locking for details.
...

Drift detected after migration reset

Hi, I'm having trouble with adding changes to our db because of Drift detected issue, event after. I did the ff migration reset --force ``` ...

Supabase with Pulse and Accelerate

Hi! I am setting op Supabase in combination with Fly, Pulse and Accelerate. I received two URLS: A connection pooler URL A direct URL ...

Whenever you extend your PrismaClient with Pulse, you don't have access to $on anymore. Why?

Why is it possible to do this: ```ts const client = new PrismaClient({ log: [...
No description

deep nested create takes so much time to complete

PFA reproduction code ` npm install npx prisma generate npm run dev...

Return Type With Relations

Hello there, I have a quick question about return type with relation. If I have this sort of query: ```ts...