https://www.prisma.io/ logo
Join Slack
Powered by
# orm-help
  • u

    {Pedrolima}

    07/29/2022, 6:46 PM
    also another question, would anyone do wp headless with prisma only, without using WPgraphql?
  • g

    Guilherme Nimer

    07/29/2022, 8:12 PM
    Hey guys, i'm struggling to create a record with nested table using this model, even with a single record in the tags table i'm getting this error
    ✅ 1
    a
    • 2
    • 4
  • u

    0xsapphir3

    07/30/2022, 3:25 AM
    Hi! Is there a library for converting string prisma model into a json type object (all the models with the datatype)?
    ✅ 1
    m
    n
    • 3
    • 8
  • r

    Rutik Wankhade

    07/30/2022, 6:20 AM
    hello, I am using Prisma in Nextjs with Planetscale as a database. I have deployed the app. I pushed all the schema changes to the main branch which is not promoted as prod branch yet. Do I need to run the migrate command or it does automatically? (also I can get the data in my deployed app)
    ✅ 1
    n
    • 2
    • 1
  • c

    Christoffer

    07/30/2022, 1:10 PM
    Is there a guidance when to use cuid vs uuid? is cuid better performance?
    ✅ 1
    n
    • 2
    • 1
  • j

    Jayek

    07/30/2022, 4:26 PM
    How do you test codebase which uses prisma in stack, I've currently solved that with domain model with mocked repository on simple array used but tests but I wonder how community does that.
    ✅ 1
    m
    n
    • 3
    • 2
  • g

    Geebrox

    07/31/2022, 3:10 AM
    How can I create a field that starts with underscore (
    _
    ) in prisma schema? Currently it throws an error saying that it is invalid field
    ✅ 1
    n
    • 2
    • 1
  • v

    Viktor Demčák

    07/31/2022, 5:48 AM
    Hey, can I subscribe to changes in a table using prisma?
    ✅ 1
    n
    s
    • 3
    • 5
  • v

    vijay krishna

    07/31/2022, 6:15 AM
    Hey, for the below model, how to select bin_to_uuid(id)
    Copy code
    model User {
     
      id      Bytes    @id @db.Binary(16) @default(dbgenerated("(uuid_to_bin(uuid()))"))
      email   String   @unique @db.VarChar(320)
      name    String?
      contact String   @db.VarChar(15)
    }
    👀 1
    n
    • 2
    • 2
  • f

    Felipe Paz

    07/31/2022, 10:38 AM
    Hey all, I hope everyone is ok. Do you know how to create a DateTime field with default value "now"? I have the field
    publishedAt
    and it should have the same value that the field
    createdAt
    . I tried
    publishedAt: DateTime! @default(now())
    ,
    publishedAt: DateTime! @default(value: "now()")
    ,
    publishedAt: DateTime! @default(value: Date.now())
    ,
    publishedAt: DateTime! @default(@createdAt)
    and none of this options worked as expected. Is there a possibility to create a DateTime field with a default value without being the createdAt and UpdatedAt fields?
    👀 1
    m
    n
    • 3
    • 6
  • m

    Michael Jay

    07/31/2022, 3:14 PM
    I'm getting ready to host my DB for the first time - just been running it locally while I create my application. I'm creating a fresh db instance on Cloud SQL. When I was going through the first Prisma tutorial, I created a DB migration file - but I've been using
    prisma db push
    to update my db. If I'm understanding correctly, I haven't used my migration file at all. Since I have a fresh DB, is there anything wrong with deleting my initial migration file since I've made quite a few changes to the Prisma schema that aren't in the initial migration, and since the DB is new?
    ✅ 1
    a
    n
    • 3
    • 6
  • a

    Adimac93

    07/31/2022, 3:18 PM
    Hey! Is it possible to limit choice of
    User
    Profile
    based on
    Profile[]
    available in
    School
    ?
    ✅ 1
    m
    • 2
    • 20
  • l

    Logan

    08/01/2022, 12:52 AM
    Hey. I'm following mongodb docs for prisma but I'm getting this erorr:
    Copy code
    error: Error parsing attribute "@default": The function auto is not a known function.
      -->  schema.prisma:11
       | 
    10 | model Session {
    11 |   id           Bytes    @id @default(auto()) @map("_id") @db.ObjectId
    If I use
    dbgenerated
    instead, i get told to use
    auto()
    ... I am on version
    "@prisma/client": "^4.1.1",
    ✅ 1
    n
    • 2
    • 4
  • l

    Logan

    08/01/2022, 12:53 AM
  • j

    Jy

    08/01/2022, 1:48 AM
    Hello! Wondering if anybody can help me with an issue I've been struggling with. I have an
    image
    table that has a many to many relationship with both with
    users
    and
    figures
    . What I'm trying to accomplish is create those 2 resources with images attached without duplicating image entries. If I can succeed in getting
    connectOrCreate
    to work that would probably be what I need. As part of my experimenting I created a unique field
    path_hash
    on
    image
    that tries to uniquely identify an image using an md5 hash of the path (since I don't know the id of a potentially pre-existing image as I'm creating it) Whenever I'm creating a would-be duplicate I get this:
    Copy code
    Running seed command `ts-node --compiler-options {"module":"CommonJS"} prisma/seed.ts` ...
    PrismaClientKnownRequestError: 
    Invalid `prisma.user.upsert()` invocation:
      Unique constraint failed on the constraint: `PRIMARY`
    at RequestHandler.handleRequestError [...removed file path]
    code: 'P2002',
      clientVersion: '4.1.1',
      meta: { target: 'PRIMARY' }
    Any ideas? I don't wanna make too much noise in the channel so I can add my models/queries in thread replies if needed
    👀 1
    a
    • 2
    • 7
  • p

    Paul Obayuwana

    08/01/2022, 10:11 AM
    hello here is a sample of my code. the code is working in deployment, but not working in production. const community = await prisma.community.update({ where: { adminId: commAdmin, }, data: { members: { set: [{ id: session.user.id }], }, }, }) it brought out this error while I was trying to deploy Type error: Property 'id' does not exist on type '{ name?: string; email?: string; image?: string; }'. what do I do?
    ✅ 1
    👀 1
    s
    n
    • 3
    • 4
  • a

    Adeodatus Abdul

    08/01/2022, 11:13 AM
    hello! @here
    👋 2
  • i

    Iradukunda Irenee

    08/01/2022, 11:16 AM
    help me to welcome our newest member@Adeodatus Abdul , Adeodatus is Rwandan Senior software engineer. currently he is working in company called harakameds as fullstack , he is MERN developer in addition he is prisma experts
    👋 2
  • i

    Iradukunda Irenee

    08/01/2022, 11:16 AM
    welcome adeo
    a
    v
    • 3
    • 3
  • m

    Michael Jay

    08/01/2022, 5:14 PM
    I'm trying to run Prisma in a container, and I'm getting Module @prisma/client has no exported member 'X' for all of my models. I'm pretty sure it's just because I didn't run npx prisma generate in my Dockerfile. but it looks like the build is ignoring the npx command. What are my options here? I installed prisma as a dev dependency, so I can't run prisma commands after instlall.
    ✅ 1
  • r

    Richard Ward

    08/01/2022, 6:54 PM
    Hi @Michael Jay - you can use the "postinstall" script in your
    package.json
  • r

    Richard Ward

    08/01/2022, 6:55 PM
    Copy code
    "scripts": {
      "postinstall": "prisma generate" # or however you may need to call it, npx prisma generate, etc..
      "build": "....",
      "start": "...."
    }
    😍 1
    m
    • 2
    • 3
  • a

    Alex Vilchis

    08/01/2022, 7:51 PM
    Hi Prisma team 👋 I'm getting the following error when upgrading MySQL to version 8.0.30:
    ✅ 1
    r
    • 2
    • 4
  • j

    Justin Wenning

    08/01/2022, 8:26 PM
    I’m currently deploying an app using Prisma using AWS Elastic Beanstalk’s Nodejs platform. The only way I’ve been able to get migrations and seeding to run before building/starting the app is to do a ton of workarounds. I have to manually run the npm installation, and my start script is just a long chain of one-off scripts before actually starting Node (
    npm run db:migrate && npm run db:seed && npm run all:build && node ./dist/server/index.js
    ). Does anyone have a documented method of getting this to work through platform hooks (or whatever the intended method is)? What I’m doing seems super hacky.
    ✅ 1
    n
    • 2
    • 6
  • a

    Alex Vilchis

    08/01/2022, 8:57 PM
    Is there a way to run
    prisma generate
    without throwing an error if the variable
    DATABASE_URL
    is not present? I need to just build my app
    ✅ 1
    n
    • 2
    • 3
  • t

    Trevor Dilley

    08/01/2022, 10:45 PM
    Hey folks, perhaps a silly question but if I run
    prisma migrate deploy
    as one of the first commands during a load balanced deployment (Say AWS ECS with multiple servers) will the multiple servers stomp on each other when deploying to the same database? In the past I think a Java dev mentioned Flywheel is able to manage migrations on LoadBalanced fleets, so I'm curious if I need a separate pipeline step to deploy migrations before updating servers, or will the first server to come up manage the migration and the other servers will wait for it to complete? Thanks!
    ✅ 2
    n
    • 2
    • 3
  • m

    Michael Jay

    08/02/2022, 4:56 AM
    If someone can help me put the pieces of my puzzle together - I would greatly appreciate it. The problem: I have CD set up to create containers to use in GCP Cloud Run. However, for my image to successfully create a container, it seems like Prisma has to be able to connect to the DB, which is hosted on Cloud SQL. However, I'm trying to connect a Cloud Run service to the DB - but the image can't create a container unless Prisma is connected to the DB... Clearly there's a lot of cloud mess to fix here, but this problem does seem unique to Prisma (as far as I can tell), so I thought I'd give it a shot asking here. One last piece of the puzzle - and maybe this actually helps. GCP points toward this repo in its primer on connecting Cloud Run to Cloud SQL. In it, they specify how to initialize a TCP connection pool for Cloud SQL. https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/HEAD/cloud-sql/mysql/mysql/connect-tcp.js
    l
    • 2
    • 5
  • p

    Pieter

    08/02/2022, 8:02 AM
    Where is the prisma data proxy hosted? AWS or GCP? Which regions are available?
    ✅ 1
    n
    • 2
    • 2
  • a

    Adeodatus Abdul

    08/02/2022, 8:12 AM
    Welcome @Yves Ivad HABIMANA . this is Prisma community.
  • m

    Michael Roberts

    08/02/2022, 9:55 AM
    Hey, I’m currently seeing the following warning within a pnpm / turborepo monorepo :
1...602603604...637Latest