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

    mohammad nowresideh

    05/11/2021, 10:30 AM
    hi everyone, I'm using 
    graphql
     and 
    prisma
     with postgres database, when i try to deploy 
    schema.graphql
     file with 
    prisma1 deploy
     command it gives me an error.
    Copy code
    {
      "data": {
        "addProject": null
      },
      "errors": [
        {
          "message": "Whoops. Looks like an internal server error. Search your server logs for request ID: local:ckoj44v3i02hc0877ny7w1j6q",
          "path": [
            "addProject"
          ],
          "locations": [
            {
              "line": 2,
              "column": 9
            }
          ],
          "requestId": "local:ckoj44v3i02hc0877ny7w1j6q"
        }
      ],
      "status": 200
    }
    docker logs:
    Copy code
    Warning: Management API authentication is disabled. To protect your management server you should provide one (not both) of the environment variables 'CLUSTER_PUBLIC_KEY' (asymmetric, deprecated soon) or 'PRISMA_MANAGEMENT_API_JWT_SECRET' (symmetric JWT).
    
    {"key":"error/unhandled","requestId":"local:ckoj44v3i02hc0877ny7w1j6q","payload":{"exception":"org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint \"Project_pkey\"\n Detail: Key (id)=(reviews$default) already exists.","query":" mutation addProject($name: String! $stage: String! $secrets: [String!]) {\n addProject(input: {\n name: $name,\n stage: $stage\n secrets: $secrets\n }) {\n project {\n name\n }\n }\n }\n ","variables":"{\"name\":\"reviews\",\"stage\":\"default\",\"secrets\":null}","code":"0","stack_trace":"org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2433)\\n org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2178)\\n org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:306)\\n org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441)\\n org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365)\\n org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:155)\\n org.postgresql.jdbc.PgPreparedStatement.execute(PgPreparedStatement.java:144)\\n com.prisma.connector.shared.jdbc.SharedSlickExtensions.$anonfun$insertToDBIO$1(SharedSlickExtensions.scala:37)\\n com.prisma.connector.shared.jdbc.SharedSlickExtensions.$anonfun$insertToDBIO$1$adapted(SharedSlickExtensions.scala:37)\\n com.prisma.connector.shared.jdbc.SharedSlickExtensions.$anonfun$jooqToDBIO$1(SharedSlickExtensions.scala:56)\\n slick.jdbc.SimpleJdbcAction.run(StreamingInvokerAction.scala:70)\\n slick.jdbc.SimpleJdbcAction.run(StreamingInvokerAction.scala:69)\\n slick.basic.BasicBackend$DatabaseDef$$anon$3.liftedTree1$1(BasicBackend.scala:276)\\n slick.basic.BasicBackend$DatabaseDef$$anon$3.run(BasicBackend.scala:276)\\n java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\\n java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\\n java.lang.Thread.run(Thread.java:748)","message":"ERROR: duplicate key value violates unique constraint \"Project_pkey\"\n Detail: Key (id)=(reviews$default) already exists."}}
    r
    • 2
    • 2
  • j

    James

    05/11/2021, 1:24 PM
    I've hit a problem with
    prisma generate
    on my Bitbucket pipelines as of 24 hours ago, can't seem to solve it. I've tried updating to latest version (2.22.1), as well as changing binaryTargets = ["debian-openssl-1.1.x"] (was native). I'm using image: node:14-buster for the runner. The problem i s it hangs forever with no output other than
    Copy code
    + NODE_OPTIONS=--max_old_space_size=3333 yarn prisma generate
    yarn run v1.22.5
    $ /opt/atlassian/pipelines/agent/build/node_modules/.bin/prisma generate
    Prisma schema loaded from prisma/schema.prisma
    ✅ 1
    j
    • 2
    • 25
  • m

    Mattias Ottosson

    05/12/2021, 3:58 PM
    Hi all! I started my first prisma project today and tried out the example at https://github.com/prisma/prisma-examples/tree/latest/javascript/rest-express However, I immediately ran into some problems that I can’t seem to resolve. I’m running the example code in a docker compose setup, one node 16 container for the sample code and a postgres 13.2 image for the db. As you can see, the database gets created, but then i get a connection error. Any ideas what on what I might have done wrong? Any pointers in the right direction would be greatly appreciated.
    Copy code
    root@627895f87344:/app# npx prisma migrate dev --name init
    Environment variables loaded from prisma/.env
    Prisma schema loaded from prisma/schema.prisma
    Datasource "db": PostgreSQL database "opti_development", schema "public" at "db:5432"
    
    PostgreSQL database opti_development created at db:5432
    
    Response: Can't reach database server at `db`:`5432`
    
    Please make sure your database server is running at `db`:`5432`.
    Error: UserFacingError
    Connecting to the db with psql works just fine:
    Copy code
    root@627895f87344:/app# psql -h db -U user
    Password for user user:
    psql (11.11 (Debian 11.11-0+deb10u1), server 13.2)
    WARNING: psql major version 11, server major version 13.
             Some psql features might not work.
    Type "help" for help.
    
    user=#
    Using sqlite works just fine:
    Copy code
    root@627895f87344:/app# npx prisma migrate dev --name init
    Environment variables loaded from prisma/.env
    Prisma schema loaded from prisma/schema.prisma
    Datasource "db": SQLite database "dev.db" at "file:./dev.db"
    
    The following migration(s) have been created and applied from new schema changes:
    
    migrations/
      └─ 20210512160133_init/
        └─ migration.sql
    
    Your database is now in sync with your schema.
    
    ✔ Generated Prisma Client (2.22.1) to ./node_modules/@prisma/client in 389ms
    schema.prisma as following
    Copy code
    generator client {
      provider = "prisma-client-js"
    }
    
    datasource db {
      provider = "postgresql"
      url      = "<postgresql://user:password@db:5432/opti_development>"
    }
    
    model User {
      id    Int     @id @default(autoincrement())
      email String  @unique
      name  String?
      posts Post[]
    }
    
    model Post {
      id        Int      @id @default(autoincrement())
      createdAt DateTime @default(now())
      updatedAt DateTime @updatedAt
      title     String
      content   String?
      published Boolean  @default(false)
      viewCount Int      @default(0)
      author    User?    @relation(fields: [authorId], references: [id])
      authorId  Int?
    }
    b
    d
    +2
    • 5
    • 14
  • i

    Ist Vicente

    05/12/2021, 7:42 PM
    apologies for this newbie question… is it required to have prisma/schema.prisma and have another schema definition in /src directory for nexus? i’d like to follow code-first philosophy so I thought for that i’d use nexus definition but in the example https://github.com/prisma/prisma-examples/tree/latest/typescript/graphql both our maintained or updated? I’m just a bit confused, it’s kind a redundant to update both if I want to add a new table or have some db modification? or does the definition in nexus is just for letting it know about database so you can perform query and mutation but not to be used for migration?
    j
    • 2
    • 1
  • i

    Isaac Lopez

    05/13/2021, 1:23 AM
    Hi guys, does anyone know why I can't get the cookies in my context. I am using prism and apollo-server. Previously I was using apollo-server-express and nothing was happening, I don't know what is happening now Can somebody help me? I only get an error code when I try to access res.cookies
  • h

    Hào Nguyễn Đức

    05/13/2021, 3:19 AM
    I'm following the tutorial on https://www.howtographql.com/graphql-js/7-subscriptions/. But the 
    subscriptions-transport-ws
     library is not being actively maintained. It is recommended that you use the graphql-ws library instead.
  • h

    Hào Nguyễn Đức

    05/13/2021, 3:28 AM
    I've tried to navigate throught the graphql-ws docs but it's unapproachable for beginners like me.
  • y

    y0on2q

    05/13/2021, 6:20 AM
    Hello, I use prisma2 with nestjs and mysql. I want use TDD. but I can't find tutorial or best-practice. How I can TDD with prisma?
  • v

    vnadygin

    05/13/2021, 9:32 AM
    Hello. I am trying to find any way we can get query cost. I know they I can copy the generated SQL and add EXPLAIN in front of it. But maybe where is the better way to do it?
    r
    j
    j
    • 4
    • 3
  • d

    Divlo

    05/13/2021, 1:17 PM
    Hello! 👋
  • d

    Divlo

    05/13/2021, 1:22 PM
    I'm new to Prisma and looking for help to reuse logic with it. 😅 Can someone could help me ? I posted all the informations in this GitHub discussion : https://github.com/prisma/prisma/discussions/7075
  • c

    CCBCodeMonkey

    05/13/2021, 11:24 PM
    hey I am running into strangeness with schema...
  • c

    CCBCodeMonkey

    05/13/2021, 11:24 PM
    I have two models I am trying to link like this
  • c

    CCBCodeMonkey

    05/13/2021, 11:26 PM
    Copy code
    model Model {
      id Int @id @default(autoincrement())
      domain String? @unique
      otherModels OtherModel[]
    }
    
    
    model OtherModule {
      id        Int      @id @default(autoincrement())
      modelId Int
      modelDomain String?
      model Model @relation(fields: [modelId, modelDomain], references: [id, domain])
    }
  • c

    CCBCodeMonkey

    05/13/2021, 11:27 PM
    and I get an error like this:
  • c

    CCBCodeMonkey

    05/13/2021, 11:28 PM
    Copy code
    Error validating: The argument `references` must refer to a unique criteria in the related model `Model`. But it is referencing the following fields that are not a unique criteria: id, domain
    r
    • 2
    • 1
  • c

    CCBCodeMonkey

    05/13/2021, 11:29 PM
    which I don't understand because both are unique(id, domain)
  • r

    Rodrigo Scomação do Nascimento

    05/13/2021, 11:38 PM
    Hello to everyone! 😄
  • r

    Rodrigo Scomação do Nascimento

    05/13/2021, 11:47 PM
    First of all, love Prisma! Awesome TypeScript support!
  • r

    Rodrigo Scomação do Nascimento

    05/13/2021, 11:48 PM
    Now a quick question: what's the proper way to develop gRPC services/protos/schemas for Date types in TypeScript?
  • r

    Rodrigo Scomação do Nascimento

    05/13/2021, 11:49 PM
    XD
  • g

    Gavril

    05/14/2021, 2:04 PM
    Hi everyone! I am a full-stack web developer. I am looking for long term job position. Thank you.
  • d

    Daniel Garcia

    05/14/2021, 2:45 PM
    Hello to everyone!
  • r

    Rob Moore

    05/14/2021, 5:06 PM
    Best practice for multiple services using Prisma ORM with the same database? I am using next-auth for authentication, which handles auth with users, accounts, and sessions tables in the data base. I also have a separate server which connects to the same database and needs to access those users (but also do other things that the next side of my app doesn’t need to touch). I want to use Prisma ORM on both of these services which both interact with the same underlying database. What is the best practices for keeping schemas in sync? Is it ok to just manually copy over the schema.prisma files and migrations over and npx prisma generate?
    c
    • 2
    • 2
  • v

    Vladimir Sanchez

    05/14/2021, 5:14 PM
    Hello, what is the best channel to ask questions about the graphQl Playground?
    r
    • 2
    • 1
  • o

    Ozgur SARIOGLAN

    05/14/2021, 8:56 PM
    can you guys help me?
    j
    j
    • 3
    • 5
  • j

    John McElreavey

    05/14/2021, 11:17 PM
    Has anyone had any luck using the Prisma namespace on the frontend? I'd like to use the input args objects which get generated as types for my requests which I send to the API however it doesn't seem possible currently to import Prisma and then access for example UserCreateArgs type without the build complaining about missing modules
    s
    a
    • 3
    • 4
  • s

    Sayer Tindall

    05/15/2021, 12:54 AM
    hey everyone, does anyone know how to utilize
    Prisma.validator
    to generate types for nested includes as such:
  • s

    Sayer Tindall

    05/15/2021, 12:55 AM
    Untitled.ts
  • a

    Alex Dumbreck

    05/15/2021, 12:03 PM
    HI all o/
1...432433434...637Latest