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

    Jonathan Stevens

    10/16/2021, 9:23 PM
    Heya, Just wondering if anyone would be able to point me to the latest and correct documentation for deploying to cloud functions (GCF or Lamba)?
    a
    • 2
    • 1
  • r

    Richard Prins

    10/16/2021, 10:06 PM
    In a situation where 2 apps could possibly share the same database (think blitzjs app with prisma, and possibly a separate NodeJS backend with prisma, that ultimately work together but the backed server does more computational work while the blitz app handles all the web app queries and mutations for the UI engagement, would both apps need to share the same schema.prisma file contents, as I like even if the backend server didn’t touch some of the prisma tables that the front end does, or vice versa, to make sure everything is in sync, would it be smart to keep the two identical?
    r
    • 2
    • 1
  • n

    Nathaniel Babalola

    10/16/2021, 10:39 PM
    is there a findOrcreate method in Prisma ? Apparently prisma doesn't have a findOrCreate, but rather passing an empty object to the update property in upsert. A decision hasn't been reached yet on this issue https://github.com/prisma/docs/issues/640 , because I can't find any upsert example in the docs that uses an empty update object, or a findOrCreate section. Please fix @Joël
    r
    • 2
    • 3
  • w

    William Stanley

    10/17/2021, 3:23 AM
    I have some connected relations that I can't help but feel there is a better way to query:
    User -in-> Organization -has_many-> Skus
    At the moment I am doing:
    Copy code
    let inventory = await prisma.user
        .findUnique({ where: { id } })
        .organization()
        .skus({
          where: {
            product: {
              ...(name && { name: { contains: name, mode: "insensitive" } }),
            },
          },
          select: {
            id: true,
            organization: true,
            condition: true,
            language: true,
            binLocation: true,
            inventoryEntries: true,
            product: {
              select: { uuid: true, identifiers: true, name: true },
            },
          },
        });
    is there a way to do it from:
    prisma.sku.findMany()
    or am I needlessly worried?
    r
    • 2
    • 1
  • t

    Tom

    10/17/2021, 7:28 AM
    If you ever face the error:
    Unable to init PersistenceStore undefined
    in prisma studio: It could be because of the firefox setting
    Firefox will never remember history
  • u

    user

    10/17/2021, 9:17 AM
    Connect Dev Africa #2: Segun Adebayo - Building Accessible Design Systems with React

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

    This is a QnA session where Segun and Alex discuss the fundamentals of building accessible design systems, patterns and best practices, accessibility, testing, state management and how to design good reusable components. ✨ Join our Prisma Meetup group here: https://www.meetup.com/connect-dev-africa/ Follow Segun Adebayo on Tiwtter: https://twitter.com/thesegunadebayo Next: 👉 Check Next video: Elarian - A Tale of Communication & Data -

    https://youtu.be/A_lolqYfP4M▾

  • c

    Craig Bennett

    10/18/2021, 2:37 AM
    I am having a deployment issue I am hoping someone can help me with here. I have been using Prisma with NextJS locally with no problem while I have been developing my app. However, now that I have deployed to Vercel, I am getting this error: Error: error: Environment variable not found: DATABASE_URL I have set the environment variable in my vercel settings (copied and pasted from my .env file). Anyone have any clues as to why this is happening in the deployed app but not locally?
    ✅ 1
    • 1
    • 1
  • z

    z

    10/18/2021, 6:08 AM
    does anybody know what tool is used to generate these beautiful diagram/flow chart?
    💅🏽 1
    👀 2
    💅 1
    plus one +1 1
    n
    • 2
    • 1
  • m

    Magne Skutle

    10/18/2021, 7:40 AM
    Hi! I would like my generated prisma models to have an "Entity" postfix (e.g UserEntity, PostEntity). Is there a way to make prisma do that automatically, or do I have to name them "UserEntity" etc in my schema? Would be nice to have the brevity of "User", "Post" etc in my schema but still get the Entity-postfix in my generated typescript models 🙂
    r
    • 2
    • 2
  • s

    Sunao Suzuki

    10/18/2021, 8:46 AM
    Hi , is there any way to customize generating  PrismaClient process? Now I am implementing the backend of Saas and the strategy of db is shared table(table have tenant_id column). To add the value of tenant at create and add the where tennatId = XXXX at findXXXXX and so on, I am using Prisma Middleware now. I have one problem now and that is like this (below is example). User_profile table have tenant_id column which is required. And in the type definition of prisma.userProfile.create , tenant is required too , but the best for us is tenant is not in this type definition (because the value is decided by Middleware). So I want to customize generating  PrismaClient process. (It is the best solution for me that I can add @MiddlewareCreateValue to tenant attribute in my schema )
    r
    • 2
    • 3
  • m

    Martí Crespí

    10/18/2021, 10:16 AM
    Hi, is there any change about
    DATABASE_URL
    located in schema.prisma file from prisma 2.30.0 to 3.2.1? I'm using NestJS with prisma and now when I try to start the app is throwing an error, and before to upgrade it didn't happen.. My app when starts get the variable from consul but it seems that prisma requires before to load the app..
    r
    • 2
    • 13
  • m

    Martí Crespí

    10/18/2021, 10:16 AM
    Copy code
    [Nest] 8 - 10/18/2021, 10:08:42 AM LOG [InstanceLoader] InternalModule dependencies initialized +1ms
    
    [Nest] 8 - 10/18/2021, 10:08:42 AM LOG [InstanceLoader] ScheduleModule dependencies initialized +4ms
    
    [Nest] 8 - 10/18/2021, 10:08:42 AM LOG [InstanceLoader] CronModule dependencies initialized +1ms
    
    [Nest] 8 - 10/18/2021, 10:08:42 AM LOG [InstanceLoader] GraphqlModule dependencies initialized +0ms
    
    [Nest] 8 - 10/18/2021, 10:08:42 AM LOG [InstanceLoader] GraphQLSchemaBuilderModule dependencies initialized +2ms
    
    [Nest] 8 - 10/18/2021, 10:08:42 AM LOG [InstanceLoader] GraphQLModule dependencies initialized +1ms
    
    (node:8) UnhandledPromiseRejectionWarning: Error: error: Environment variable not found: DATABASE_URL.
    
    --> schema.prisma:12
    
    |
    
    11 | provider = "postgresql"
    
    12 | url = env("DATABASE_URL")
    
    |
    
    
    Validation Error Count: 1
    
    at LibraryEngine.loadEngine (/node_modules/@prisma/client/runtime/index.js:26778:21)
    
    at async LibraryEngine.instantiateLibrary (/node_modules/@prisma/client/runtime/index.js:26708:7)
    
    (Use `node --trace-warnings ...` to show where the warning was created)
    
    (node:8) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see <https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode>). (rejection id: 1)
    
    (node:8) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
    
    (node:8) UnhandledPromiseRejectionWarning: Error: error: Environment variable not found: DATABASE_URL.
    
    --> schema.prisma:12
    
    |
    
    11 | provider = "postgresql"
    
    12 | url = env("DATABASE_URL")
  • m

    Martí Crespí

    10/18/2021, 10:20 AM
    Here you can see the same app log working (left) with prisma 2.30.0 and only upgrading prisma to 3.2.1 in the right side..
  • n

    Neil Oliver

    10/18/2021, 10:55 AM
    I have a column with mixed data (text and numbers). I want to be able to do an aggregation on a subset of the data that only contains numerical data, however the column type is set to TEXT (postgres). Is there any way i can achieve what i am after? Thanks!
  • p

    Paulo Spiguel

    10/18/2021, 12:26 PM
    Hi, I'm having difficulty in a project setup with Prisma, Docker, Postgres and nestjs. Can anyone help me with this error?
    Copy code
    node:29) UnhandledPromiseRejectionWarning: Error: Query engine library for current platform "linux-musl" could not be found.
    app-api     | You incorrectly pinned it to linux-musl
    app-api     | 
    app-api     | This probably happens, because you built Prisma Client on a different platform.
    app-api     | (Prisma Client looked in "/usr/app/node_modules/@prisma/client/runtime/libquery_engine-linux-musl.so.node")
    app-api     | 
    app-api     | Searched Locations:
    app-api     | 
    app-api     |   /usr/app/node_modules/.prisma/client
    app-api     |   /home/paulospiguel/www/dkpa/doggie/api/node_modules/@prisma/client
    app-api     |   /usr/app/node_modules/@prisma/client
    app-api     |   /usr/app/node_modules/.prisma/client
    app-api     |   /usr/app/prisma
    app-api     |   /tmp/prisma-engines
    app-api     |   /usr/app/node_modules/.prisma/client
    app-api     | 
    app-api     | 
    app-api     | To solve this problem, add the platform "linux-musl" to the "binaryTargets" attribute in the "generator" block in the "schema.prisma" file:
    app-api     | generator client {
    app-api     |   provider      = "prisma-client-js"
    app-api     |   binaryTargets = ["native"]
    app-api     | }
    app-api     | 
    app-api     | Then run "prisma generate" for your changes to take effect
    r
    • 2
    • 1
  • o

    Oliver St.

    10/18/2021, 12:37 PM
    you have probably another OS in the docker container (alpine, ubuntu… -> linux) so you have to tell this prisma. Try this in you schema.prisma file:
    Copy code
    generator client {
      provider      = "prisma-client-js"
      binaryTargets = ["native", "linux-musl"]
    }
    🙌 1
  • p

    Paulo Spiguel

    10/18/2021, 12:57 PM
    thaks @Oliver St.
  • m

    Mykyta Machekhin

    10/18/2021, 1:29 PM
    Hi guys. Now our project is going through a big refactoring stage, at the end of which we want to get the project much cleaner. We have significantly improved our database schema. And now it will rarely change. At the same time, I am concerned that there are a huge number of historical migrations in the directory with migrations. I would really like to squash them into one. Realizing that there is no standard mechanism for this, I developed my own strategy for how this can be done on the production DB. Someone confirm that I think it is correct and that no data should be lost First, locally (on the dev) I delete all migrations, start the process of rolling migrations, at the output of which I get 1 migration in my migrations folder. It now contains a script for creating the entire current database schema Then I go to the database on production, there I delete all rows from the table with migrations and add 1 single row with the name of the locally generated migration and mark it as completed. Thus, when redeploying on prod, the prisma will not do anything, since it will see that the migration with the same name has already been applied to the database. It is worth saying that at the moment we have 1 DB instance for production, so it should be pretty painless
  • i

    Ibad Shaikh

    10/18/2021, 1:43 PM
    Hi👋 How to rollback a migration even if it is not in failed state. @Ryan Please guide 😊
    r
    d
    • 3
    • 2
  • y

    Yassine

    10/18/2021, 1:45 PM
    Hey everyone, Does anyone have an idea as to why this is happening https://github.com/prisma/prisma/issues/9795 We can't launch because of that.
    r
    • 2
    • 4
  • e

    Edward Baer

    10/18/2021, 2:05 PM
    @Ryan Along the same line as @Ibad Shaikh question a few minutes ago. Is there a way to mark a migration as completed successfully, other than just the finished_at date ? I have a couple of migrations that were run in production, but subsequently had to be slightly modified. The database had to be tweaked to match by hand in production, as the only way to execute the migrations is with a new deployment. It keeps complaining about the migrations having changed, and locally will not create a new migration without completely resetting the database. Even bringing the database locally, and trying to get it synchronized by hand doesn't solve the problem, because of the migration checksums. Couldn't the reset only be applied to tables that changed or preferably allow the creation of new migrations since there is no way to recalculate the migration checksum ?
  • i

    Ibad Shaikh

    10/18/2021, 3:07 PM
    Hello, I am showing the output of this migration command just to ensure that my database and schema are properly synced. PS E:\Work> npx prisma migrate dev Environment variables loaded from .env Prisma schema loaded from prisma\schema.prisma Datasource "db": MySQL database "test-db" at "localhost:3306" Already in sync, no schema change or pending migration was found. ✔️ Generated Prisma Client (3.2.1) to .\node_modules\@prisma\client in 896ms The actual issue is addressed here: I recently added a field price Int? in my offers table. I have attached the migration.sql screenshot. I have attached the screenshot of Prisma studio as well in which it is showing the price field in the fields list. I have also attached the screenshot of the postman request. (You can clearly see the error it is throwing in response) But the issue is when I try to fetch an offer it throws an error message : "\nInvalid 
    prisma.offer.findFirst()
     invocation:\n\n\n  Failed to validate the query: 
    Field does not exist on enclosing type.
     at `Query.findFirstoffer.offer.price`", My query to fetch offer: const offer = await prisma.offer.findFirst({     where: {       id: Number(req.params.id),       is_active: true,     }   }) Unable to figure out why it is not considering price as a field in the offer table and throwing Field does not exist on enclosing type. (Struggling with this for the last two days and still didn't found a solution out there) @Ryan Please guide me. Thanking you in advance :)
    a
    • 2
    • 1
  • b

    Bruno Marques

    10/18/2021, 5:23 PM
    Hey guys, anyone knows how to setup a Next.js App with Prisma on a CPanel host?? I am wondering how I can connect it to the data base?
    a
    • 2
    • 1
  • j

    Jason Abbott

    10/18/2021, 6:47 PM
    SDK question: does the DMMF not include data source specific types? I am writing a generator and want
    @db.VarChar(25)
    , for example, to emit code to warn/trim/whatever on more than 25 characters but none of the
    @db.
    annotations are present in the DMMF. I can only see the field is a
    String
    . Is there another way to get this information?
    a
    • 2
    • 3
  • s

    Sam

    10/18/2021, 7:26 PM
    Is this kind of query possible inside of Prisma without having to run a raw query?
    Copy code
    SELECT *
    FROM guildStats
    WHERE (guildId, TIMESTAMP) IN (SELECT guildId, MAX(TIMESTAMP)
    										FROM guildStats
    										GROUP BY guildId)
    a
    • 2
    • 1
  • s

    Simon Betton

    10/18/2021, 8:34 PM
    Hello, I using Prisma + TypeScript – I have set an optional database field, however the generated types are not optional. For example: Database field:
    createdAt         DateTime?       @default(now())
    Generated TypeScript:
    createdAt: Date | null
    Is this expected? Is this configurable to change? Otherwise I have to pass a value for these optional fields..
    p
    j
    • 3
    • 5
  • j

    Josh

    10/19/2021, 1:47 AM
    Can anyone point me to the documentation on using aliases in select queries?
    r
    • 2
    • 2
  • h

    henry

    10/19/2021, 7:10 AM
    Anybody know a good video tutorial/course that covers How to manage user privileges with roles using prisma and rest?
  • d

    Dev__

    10/19/2021, 7:43 AM
    hello, how can I check if a
    Decimal
    in prisma is higher than 0. if I use
    >
    operators TS says it
    cannot be applied to types 'Decimal'
    r
    • 2
    • 2
  • o

    Oliver St.

    10/19/2021, 9:04 AM
    Hey guys, does anyone have experience with prisma integration tests in microservices. Technology stack is: nodejs - nestjs - prisma - (graphql) I would like to do this with testcontainers, because I also want to integrate and test the complete database. Workflow: • Setup Database testcontainer • dynamic adjust DATABASE_URL based on testcontainer port • connect/reconnect Prisma Client with new DATABASE_URL • Run test • After every test reset database (probably truncate) I didn’t find any good article or tutorial.
    r
    • 2
    • 2
1...495496497...637Latest