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

    Chris Packett

    01/14/2022, 7:35 AM
    What do I do if I created a migration in the development branch, but also want to apply it to the production branch but I can’t merge the code into prod? Would it be a problem if I created a separate migration with the same schema change in prod as a hotfix?
    s
    • 2
    • 1
  • g

    Greger gregerson

    01/14/2022, 9:10 AM
    I've got a question about the schema of prisma, when you create a model that has another model, prisma will create a id of that model:
    model Page {
    text String @unique
    bookId Int?
    }
    model Book {
    pages Page[]
    }
    I'm wondering what is the reason for that and if I then create multiple books with the same page(s) what is the purpose of that?
    s
    • 2
    • 16
  • s

    Stefan Bajić

    01/14/2022, 10:36 AM
    Why do I get a syntax error if I have a non-ascii character in an enum in my
    schema.prisma
    ? Is there a way for me to allow these characters?
  • e

    esau

    01/14/2022, 10:53 AM
    Hey guys I was just wondering what would be the best way to store a number generated by bignumber into a postgres decimal field? Thanks!
    s
    • 2
    • 9
  • m

    Moe Green

    01/14/2022, 12:34 PM
    hi guys! in Prisma is it possible to get data from the database like a sql command -
    SELECT u.name, u.email FROM users AS u
    that is, I want to say - selectively table columns? but - not all the columns that are in the table
    s
    • 2
    • 2
  • a

    Ahos

    01/14/2022, 12:56 PM
    Hi, I have to perform a few custom migrations recently as described here The tables I have use cuid to generate ids for the entries in my database, I need to move some data from one table to another but it looks like running pure SQL/PSL will not do the job cause it doesn't support
    cuid
    yet. Any idea how to solve this issue? I was thinking to let TypeORM apply migrations instead prisma then I could run migrations using ts/js, but I am not sure if the community has already some alternative. Thank you
  • j

    J

    01/14/2022, 3:21 PM
    Anyone know how many rows you can create at once with createMany?
    s
    • 2
    • 2
  • j

    J

    01/14/2022, 3:21 PM
    Trying to find what the limitations are
  • f

    Francesco Sardo

    01/14/2022, 3:22 PM
    Hello there, general question on prisma client: Why are there two ways of working with relationships? If I download the starter project with user and post, I can create an association in two ways:
    Copy code
    const user = await prisma.user.create({data: {email: ''}}) 
     const post = await prisma.post.create({data: {title: '', author: {connect: {id: user.id}}}})
    Copy code
    const user = await prisma.user.create({data: {email: ''}}) 
     const post = await prisma.post.create({data: {title: '', authorId: user.id}})
    What's the difference between the two and why are both available?
    s
    • 2
    • 2
  • j

    Johnson Detlev

    01/14/2022, 3:49 PM
    Hi, I got a question regarding unique indexes with optional values. I have a schema like this:
    Copy code
    model Thread {
      id               Int            @id @default(autoincrement())
      createdAt        DateTime       @default(now())
      updatedAt        DateTime       @updatedAt
      body             String
      user             User           @relation(fields: [userId], references: [id])
      userId           Int
      likes            Like[]         @relation("ThreadsOnLikes")
    }
    
    model Like {
      id        Int      @id @default(autoincrement())
      createdAt DateTime @default(now())
      user      User     @relation(fields: [userId], references: [id])
      userId    Int
      thread    Thread?   @relation("ThreadsOnLikes", fields: [threadId], references: [id])
      threadId  Int?
      comment   Comment? @relation("CommentsOnLikes", fields: [commentId], references: [id])
      commentId Int?
    
      @@unique([userId, threadId, commentId])
    }
    And inside a resolver I want to for example delete a like from a user for a specific threadId like so:
    Copy code
    await db.thread.update({
        where: { id: input.id },
        data: {
          likes: {
            delete: {
              userId_threadId_commentId: { userId: session.userId, threadId: input.id },
            },
          }
        }
      })
    But when I try to execute that mutation, prisma throws the following error:
    Argument commentId for data.likes.delete.userId_threadId_commentId.commentId is missing.
    When I add it to the delete argument with
    , commentId: null
    it states this error:
    Argument commentId: Got invalid value null on prisma.updateOneThread. Provided null, expected Int.
    Although inside the database the comment_id field is actually
    null
    . Is this a bug or how is this fixable?
  • j

    Julien Goux

    01/14/2022, 9:03 PM
    Hello all
  • j

    Julien Goux

    01/14/2022, 9:04 PM
    Can prisma migrate be applied to a particular postgresql schema?
  • j

    Julien Goux

    01/14/2022, 9:04 PM
    I'd like to test migrating the prima's schema over multiple postgresql schema to run integration tests in parallel
  • j

    Julien Goux

    01/14/2022, 9:05 PM
    it would also require prisma client to be able to connect to a particular schema
  • j

    Julien Goux

    01/14/2022, 9:05 PM
    Is it something doable? 🤔
  • j

    Julien Goux

    01/14/2022, 9:07 PM
    The "connecting to a particular schema" is doable by passing the schema parameter in the database URL
  • j

    Julien Goux

    01/14/2022, 9:09 PM
    Ok I got my answer : https://github.com/prisma/prisma/issues/4626#issue-766029714 😄
  • j

    Julien Goux

    01/14/2022, 9:09 PM
    I need to pass the database url to the prisma migrate command as well 🎉
  • a

    Alex Vilchis

    01/14/2022, 9:44 PM
    Hello, guys 👋 For those of you who have a GraphQL API in production, what do you use to create all of the crud functionality? I'm finding that doing all of it "by hand" get painful quick 😕
    a
    b
    c
    • 4
    • 5
  • e

    Eudes Tenório

    01/15/2022, 2:33 AM
    Hey guys. Does anyone have any examples of Docker + MongoDB + Prisma? I've been trying to make this combo for a long time, but my prism always fails due to a problem in the Replica Set.
  • u

    user

    01/15/2022, 9:43 AM
    😌 ASRM for developers: peeling Prisma stickers #shorts #asmr

    https://www.youtube.com/watch?v=F0pvRBOQWjk▾

  • w

    Wildan Alif R

    01/15/2022, 1:34 PM
    Hello guys, can i make separate model file in prisma like in laravel ?
    m
    s
    • 3
    • 4
  • c

    Chris Packett

    01/15/2022, 5:41 PM
    When there is a DB drift on a remote DB server, how do you force the DB to reset with the
    npx prisma migrate deploy
    command?
  • c

    Chris Packett

    01/15/2022, 5:42 PM
    FYI: this is the development database, not production
  • b

    Benny Kachanovsky

    01/16/2022, 12:48 PM
    Hi, is there a way to reference an existing table that is not in Prisma's schema? for example i have existing User table. Im creating a Post model in Prisma that i want to have a foreign key to User. If there is not built-in way, the best option is change the generated migration files that responsible on the addition of Post model?
  • y

    Yazid Daoudi

    01/16/2022, 2:01 PM
    hiii all, How can i create this case with prisma schema A <-----> B | C with a table like A | B | C With a, b, c as ID Its just a ternary
    s
    • 2
    • 2
  • m

    Marvin

    01/16/2022, 3:00 PM
    Hey! Is it possible to start Prisma Studio with https e.g. https://localhost:5555? It's colliding with the automatic redirect of the browser (safari & chrome) because I have my frontend & backend run with https. Or is there a better way to use ssl locally while in development like ngrok?
  • γ

    Γιώργος Κραχτόπουλος

    01/16/2022, 7:39 PM
    Any idea why 
    $queryRaw()
     generates 4 queries for one operation!? My example:
    Copy code
    await prisma.$queryRaw`SELECT id FROM public.user`
    Log output:
    Copy code
    prisma:query SELECT id FROM public.user
    prisma:query SELECT id FROM public.user
    prisma:query SELECT id FROM public.user
    prisma:query SELECT id FROM public.user
    Related comment on GitHub
  • b

    bob

    01/17/2022, 12:54 AM
    hi all
  • b

    bob

    01/17/2022, 12:55 AM
    I am running into a problem. I am trying to use findMany() and fetch a table and load all its relations. (5 relations). 1 of these relations has two sub relations. This works fine when I want to load 1 or 50 rows, but when I try to load a 100 or the total amount (1200) I get an error:
    Copy code
    Invalid `prisma.pool.findMany()` invocation:
    
      Inconsistent query result: Field outputToken is required to return data, got `null` instead.
        at cb (/home/pop/projects/freealpha/freealpha-api/dist/webpack:/freealpha-api/node_modules/@prisma/client/runtime/proxy.js:94:1)
    Are we really not able to load large sets of data with many relations in one go?
    j
    e
    • 3
    • 5
1...532533534...637Latest