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

    Traky Richard

    03/07/2022, 9:47 AM
    Please need help. Datasource “db”: PostgreSQL database “pronettest”, schema “public” at “postgres:5432" 38Error: P3006 39Migration
    20220304181545_add_client_validation_entity
    failed to apply cleanly to the shadow database. 40Error: 41Database error 42Error querying the database: db error: ERROR: column “isValidate” of relation “Group” already exists 43 0: sql_migration_connector:flavourpostgres:sql_schema_from_migration_history
  • t

    Traky Richard

    03/07/2022, 9:47 AM
    How can i do to solve this problème please 🙏
    j
    • 2
    • 2
  • j

    Justin Ellingwood

    03/07/2022, 1:51 PM
    Hey friends 👋 Just a heads up that we just published a couple of new guides on Prisma's Data Guide: Identifying slow queries in MySQL and Profiling and optimizing slow queries in MySQL Let us know if you have any feedback! Thanks!
    🙌 1
    🎉 2
  • b

    Bernat Jufré

    03/07/2022, 2:23 PM
    What the best way have a function that accepts multiple “delegates” I have a generic function that should be able to get
    const model = db[entityType]
    and return
    [model.count(), model.findMany()]
    but the TS compiler is complaining because of the different
    Delegates
    types
  • v

    Vitor Guidorizzzi

    03/07/2022, 2:30 PM
    Any updates on postgis support ? the "planned" status on the roadmap is too vague
    n
    • 2
    • 2
  • b

    Bernat Jufré

    03/07/2022, 3:16 PM
    what I’m trying to do is something like:
    Copy code
    type EntityKeys = "user" | "project" | "projectType";
    type PrismaDelegates = Pick<typeof db, EntityKeys>;
    type Entity = {
      [Key in EntityKeys]: PrismaDelegates[Key];
    }[EntityKeys];
    
    const SLUG_TO_ENTITY = {
      users: "user",
      projects: "project",
      "project-types": "projectType"
    };
    
    
    // `db` is a reference to an instance of the PrismaClient
    const model: Entity = db[SLUG_TO_ENTITY[entity as keyof typeof SLUG_TO_ENTITY] as EntityKeys];
    Then intellisense shows correctly that
    model
    has
    count
    and
    findMany
    but because their signatures are not compatible with each other I get a typing error. Any ideas?
    i
    h
    • 3
    • 2
  • j

    Julien Goux

    03/07/2022, 3:19 PM
    Hello team, is there any improvement about prisma leaking memory with jest? https://github.com/prisma/prisma/issues/8989#issuecomment-1038925980
    j
    • 2
    • 4
  • a

    AlexSPx

    03/07/2022, 5:04 PM
    Is anyone else using the prisma express session store?
    n
    • 2
    • 2
  • a

    AlexSPx

    03/07/2022, 5:05 PM
    Because I'm getting error when deleting the session
  • a

    AlexSPx

    03/07/2022, 5:05 PM
    https://github.com/kleydon/prisma-session-store/issues/76
  • m

    Moe Green

    03/07/2022, 5:58 PM
    hi, guys! I created such model:
    Copy code
    model Article {
      id             Int      @id @default(autoincrement())
      slug           String   @db.VarChar(255)
      title          String   @db.VarChar(255)
      description    String?  @db.VarChar(255)
      body           String?  @db.VarChar(255)
      createdAt      DateTime @default(now())
      updatedAt      DateTime @updatedAt
      tagList        String[]
      favoritesCount Int      @default(0)
    
      @@map("articles")
    }
    ... and then make migration with result:
    Copy code
    CREATE TABLE "articles" (
        "id" SERIAL NOT NULL,
        "slug" VARCHAR(255) NOT NULL,
        "title" VARCHAR(255) NOT NULL,
        "description" VARCHAR(255),
        "body" VARCHAR(255),
        "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
        "updatedAt" TIMESTAMP(3) NOT NULL,
        "tagList" TEXT[],
        "favoritesCount" INTEGER NOT NULL DEFAULT 0,
    
        CONSTRAINT "articles_pkey" PRIMARY KEY ("id")
    );
    ... but I have a question about this field -
    "updatedAt" TIMESTAMP(3) NOT NULL,
    because I expected that this field should be like this -
    "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP
    why did it happen? I do not understand something?
    👀 1
    i
    j
    • 3
    • 4
  • m

    Meyer BTS

    03/07/2022, 11:11 PM
    Hello, I’m going to put prisma in production for the first time and I don’t really understand how migrations work even though I’ve seen all the documentation available on prisma.io Someone would be available to explain and answer my questions about migration in general and more specifically about deployment? Thanks to all
    i
    v
    • 3
    • 3
  • c

    Chris Tsongas

    03/08/2022, 12:21 AM
    I'm noticing if I have the following columns in a model
    Copy code
    createdAt DateTime @default(now())
    updatedAt DateTime @updatedAt
    Prisma seems to set an
    updatedAt
    value a fraction of a second after the
    createdAt
    value when a record is created, even if the record wasn't updated. I don't remember that being the case when using a previous query builder (Knex.js). Anyone else notice this?
    i
    j
    • 3
    • 2
  • s

    Silen Naihin

    03/08/2022, 4:52 AM
    I'm getting the error in the screenshot below when running 'npx prisma db push' or any other invocation such as findMany or create. 'npx prisma generate' works and I'm using supabase as the db. On version 2.27
    i
    j
    • 3
    • 9
  • m

    Manthan Mallikarjun

    03/08/2022, 5:31 AM
    What's it called when you have a primary table (let's say
    posts
    ) with a column called
    type
    and if
    type
    is set to
    "public"
    you join the
    PublicPosts
    table and if it's set to
    "private"
    , it joins another table. I think django has this kind of support. Does Prisma support something like this?
    i
    j
    • 3
    • 15
  • m

    Manthan Mallikarjun

    03/08/2022, 7:43 AM
    Does anyone have any interesting ways they set up their models for tests? I configured jest so that it has a fresh DB for every test but I was wondering if anyone has come up with an interesting way to create Factories or some other way to fill in models with fake data?
    • 1
    • 1
  • a

    Adam Tretera

    03/08/2022, 9:23 AM
    Hi, guys Iam button developer :))) now starting with BE. Come to an issue with prisma ? How do I validate if f.e
    req.body
    is empty ? after POST call Is there a best practice for express api project structure ? cannot find any diffrent then all routes in index.ts
    n
    • 2
    • 4
  • a

    Andrew Valleteau

    03/08/2022, 9:45 AM
    Hi there, I'm actually trying to call a pg function via prisma.$executeRaw and a have a little troubles finding the correct syntax. My function look like so:
    Copy code
    // IN POSTGRESQL
    type permission_type (entity_id uuid, access text);
    update_permissions(target_id uuid, new_permissions permission_type[])
    
    // In Typescript
    const entityId = 'abc-def-hij'
    const newPerms = [{id: 'abc-def-hig', access: 'write'}];
    await prisma.$executeRaw(`SELECT update_permission(${entityId}, array[${Prisma.join(newPerms.map((p) => `(${p.id}, ${p.access})`)}]::permission_type[]))`);
    Would that be correct ?
    j
    • 2
    • 4
  • a

    aaron.cai

    03/08/2022, 2:25 PM
    hello everyone, does Prisma was updated the vulnerability information of CVE-2022-0847
    j
    • 2
    • 2
  • j

    Juan Orellana

    03/08/2022, 5:59 PM
    hi, is there a way to define the "start" value of an autoincrement column?
    👀 2
    j
    • 2
    • 1
  • a

    Alex Vilchis

    03/08/2022, 8:45 PM
    Hello, guys 👋 How can I optimize the performance of
    migrate dev
    ? I have aprox 120 migrations and creating a new one takes soooo long. Is there any recommended flow to clean the migration history and start fresh without causing problems in production? 🤔
    r
    t
    j
    • 4
    • 8
  • j

    jackgray

    03/08/2022, 10:13 PM
    Hi everyone! Looking for any hints on how to go about using Prisma with s3 object based storage. Is a connector for s3 select or min.io on the radar at all? from what i understand it is heavily based on SQL
    j
    • 2
    • 3
  • s

    Sajal Gupta

    03/09/2022, 4:20 AM
    Hello guys. I have a project using ObjectionJS and I would like to move it over to Prisma. Do you know of any guide or tutorial which I can use to migrate the ORM ?
    j
    n
    • 3
    • 8
  • m

    motiondev

    03/09/2022, 10:03 AM
    Hi everyone! Is there a way to enforce prisma migrate to generate BIGINT instead of BIGSERIAL for ids?
    model Denomination {
    id         BigInt      @unique @default(autoincrement()) @db.BigInt
    symbol     String      @unique
    active     Boolean
    createdAt  DateTime    @default(now()) @map("created_at") @db.Timestamp(5)
    updatedAt  DateTime    @default(now()) @map("updated_at") @db.Timestamp(5)
    @@map("denomination")
    }
    Running prisma migrate, generates the following sql scrcipt
    -- CreateTable
    CREATE TABLE "denomination" (
    "id" BIGSERIAL NOT NULL, -- Here I want BIGINT insted of BIGSERIAL
    "symbol" TEXT NOT NULL,
    "active" BOOLEAN NOT NULL,
    "created_at" TIMESTAMP(5) NOT NULL DEFAULT CURRENT_TIMESTAMP,
    "updated_at" TIMESTAMP(5) NOT NULL DEFAULT CURRENT_TIMESTAMP
    );
    Thanks in advance!
    j
    • 2
    • 6
  • n

    Nditah Samweld

    03/09/2022, 11:29 AM
    Hello Everyone, who can recommend to me a tutorial on project layout for Prisma + Nestjs + Mongodb I have have done the simple hello world. I need something for mega project.
    n
    • 2
    • 2
  • b

    Bailey McKay

    03/09/2022, 6:41 PM
    Hi all, I recently upgraded from Prisma1 to Prisma2, and I just discovered an issue with Floats. Occasionally, a float I send to my backend will appear in my Postgres database with 12 extra 9s after the number I send it. Strangely, when I call this data from the client, it looks fine. During introspection, my Prisma1 Floats were mapped to Prisma2 Floats in my Prisma Schema. I’m not sure that was right, because after some digging it seems Prisma2 Floats are now expecting the double type in Postgres. These data columns in my Postgres are numeric(65, 30) since they were created by Prisma1. I assume my issue involves this mismatch between the Prisma2 generator and my Postgres database. I had no issue with numeric(65, 30). Is there a way to tell my Prisma2 schema that I’m using numeric(65, 30), so it will behave normally? I’d rather not deal with decimal.js or rewrite any existing code. I just want it to behave as before. Thanks, Bailey
    j
    • 2
    • 10
  • o

    Octal pixel

    03/09/2022, 9:05 PM
    Is it possible to filter data within a given date , more sort group data over date ranges. The usecase is timeline chart/ data to plot charts
    a
    • 2
    • 1
  • j

    Juan Carlos Blanco Delgado

    03/10/2022, 12:50 AM
    Hello, I was wondering how can I archive version model as in revision perhaps with PostgreSQL. It looks like the approach I am taking is not allowed as
    Copy code
    Error validating composite type "System": SystemVersion refers to a model, making this a relation field. Relation fields inside composite types are not supported.
    n
    • 2
    • 5
  • g

    Gelo

    03/10/2022, 5:07 AM
    gte lte with Float not working correctly
    v
    n
    • 3
    • 3
  • s

    sagar lama

    03/10/2022, 8:48 AM
    How do you mock the whole prisma service as mentioned in https://www.prisma.io/docs/guides/testing/unit-testing for nestjs? Manually mocking prisma service for test service becomes pretty tedious as the test services grows and each query needs to be mocked, My prisma service looks like this.
    Copy code
    import { INestApplication, Injectable, OnModuleInit } from '@nestjs/common';
    import { PrismaClient } from '@~internal/partner-database/client';
    
    @Injectable()
    export class PrismaService extends PrismaClient implements OnModuleInit {
      async onModuleInit() {
        await this.$connect();
      }
    
      async enableShutdownHooks(app: INestApplication) {
        this.$on('beforeExit', async () => {
          await app.close();
        });
      }
    }
    n
    • 2
    • 1
1...552553554...637Latest