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

    Schuyler Ankele

    09/14/2021, 9:47 PM
    Hello, I'm trying to implement Prisma Migrate for an existing Postgres DB and after following the docs on doing
    prisma db pull
    to create the baseline I have a single migration created. Next, I mark the init migration as applied. But then if I run
    prisma db push
    I get an error with
    drift detected
    , with no changes to the schema. If I create a new migration I get the same error and Prisma Migrate insists on resetting the DB. I saw an issue in Github, but it was marked resolved. Has anyone else run into this or resolved it? Am I missing something in the initial setup?
    r
    • 2
    • 1
  • p

    prisma chobo

    09/14/2021, 10:30 PM
    After upgrading to version3.0.2 I get error for queryRaw:
    Copy code
    PrismaClientKnownRequestError: 
    Invalid `prisma.queryRaw()` invocation:
    Raw query failed. Code: `N/A`. Message: `N/A`
        at RequestHandler.request (/Users/kyuhakyuk/github/wallet/api/node_modules/@prisma/client/runtime/index.js:37318:15) {
      code: 'P2010',
      clientVersion: '3.0.2',
      meta: { code: 'N/A', message: 'N/A' }
    }
    For this line of code: const result = (await prisma.$queryRaw( Prisma.sql`SELECT SUM(amount) as balance FROM Balance WHERE account=“${accountId}” and deletedAt is NULL` )) as any; it used to work just find but now it does not…. a
    r
    • 2
    • 1
  • e

    Ethan Joffe

    09/14/2021, 11:12 PM
    hey there.. I am having type difficulties after upgrading from 2.x to 3.x
    Copy code
    on prisma.createOneFramework. Provided List<Json>, expected FrameworkItemCreateWithoutFrameworkInput or FrameworkItemCreateWithoutFrameworkInput or FrameworkItemUncheckedCreateWithoutFrameworkInput or FrameworkItemUncheckedCreateWithoutFrameworkInput:
    type FrameworkItemCreateWithoutFrameworkInput {
      name: String
    ....
    r
    • 2
    • 3
  • e

    Ethan Joffe

    09/14/2021, 11:13 PM
    anyone here able to help?
  • s

    Saurabh Lohiya

    09/15/2021, 7:11 AM
    I'm using
    prisma@3.0.2
    version and when I type
    prisma init
    it does not generate the 3 files like
    datamodel.graphql docker-compose.yml
    and
    prisma.yml
    yes I'm using
    node 12.19.1
    and even when I'm manuelly creating files I can't run the
    command docker-compose up -d
    it throws me the error like `ERROR: Couldn't connect to Docker daemon - you might need to run `docker-machine start default``. Help me here!!! When I run that command it shows me the message like
    Starting "default"...
    Machine "default" is already running.
    r
    • 2
    • 1
  • j

    Jonas

    09/15/2021, 8:50 AM
    Hey! So I have 1 Prisma Schema and 1 Postges Database. Now, when testing, I'd like to create 2 different postgres schemas in the database, both based on the prisma schema. Is there a way to do that? e.g. via node bindings for prisma migrate or something like that?
    👍 1
    r
    • 2
    • 2
  • j

    Jonas

    09/15/2021, 8:56 AM
    I guess an easier way to ask this is: Is there a way to migrate a database programmatically and define the created schema's name?
  • u

    user

    09/15/2021, 9:57 AM
    Prisma Meetup #7 - Nick Van Wiggeren - What's new at PlanetScale?

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

    Nick Van Wiggeren is a Director of Engineering at PlanetScale, where he runs the teams responsible for the API, front-end, database clients, and much more. Previously, he worked all over the GitHub product, and in many other developer-facing products that you know and (hopefully) love. Next: 👉 Check Previous video: Prisma Meetup #6 - Secure your Next.js + Prisma app with Auth0:

    https://youtu.be/jsWSyeI0y4c▾

    👉 Check Next video: Ryan Dsouza (@ryands1701) - Deploying Prisma on Lambda using the CDK:
  • h

    Henri Kuper

    09/15/2021, 10:26 AM
    If I have an issue with prisma studio, should I create a ticket in the prisma repo or the prisma studio repo?
    r
    • 2
    • 3
  • m

    Mischa

    09/15/2021, 10:32 AM
    I keep getting this error, even if I kill all pg backends and re-run the migration
    'Context: Timed out trying to acquire a postgres advisory lock (SELECT pg_advisory_lock(72707369)). Elapsed: 10000ms. See <https://pris.ly/d/migrate-advisory-locking> for details.',
    r
    • 2
    • 2
  • m

    Mischa

    09/15/2021, 10:32 AM
    the lock is there; I see it in pg_stat_activity. it’s stopping me from running migrations. i had a failed migration run earlier.
  • m

    Matt Young

    09/15/2021, 2:23 PM
    where do I go to get technical help with prsma?
    r
    • 2
    • 1
  • m

    Matt Young

    09/15/2021, 2:23 PM
    prisma
  • m

    Matt Young

    09/15/2021, 2:24 PM
    I am having trouble finding documentation that is accurate for some of the more obscure features
  • m

    Matt Young

    09/15/2021, 2:25 PM
    2 things I am struggling with at the moment: 1) how do I query from table A and sort by relation B fields where A has 1to1 relations with B
  • m

    Matt Young

    09/15/2021, 2:25 PM
    2) How do I query for allowable values of Enums in prisma
  • m

    Matt Young

    09/15/2021, 2:28 PM
    I keep seeing this (https://v1.prisma.io/forum/t/how-to-access-the-possible-values-of-an-enum-type-created-inside-the-console/23/2) but it is misinge the actual js where you interact with the client. This is just the query
  • e

    Eric Kidd

    09/15/2021, 3:02 PM
    Good morning. I have a group of tables that use a Rails-style polymorphic association. It looks something like this, simplified:
    Copy code
    model Post {
      id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
      tags Tag[]
    }
    
    model Comment {
      id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
      tags Tag[]
    }
    
    model Tag {
      resourceType String // One of "Post" or "Comment"
      resourceId @db.Uuid
    
      value String
    }
    For example, we could find all the tags associated with post a5c4b960-d5da-4e7b-abb5-0860bd85903d by querying:
    Copy code
    SELECT * FROM Tag WHERE resourceType = 'Post' AND resourceId = 'a5c4b960-d5da-4e7b-abb5-0860bd85903d';
    Ideally, I would like to able to write:
    Copy code
    client.source_tables.findUnique({
      where: { id: "a5c4b960-d5da-4e7b-abb5-0860bd85903d" },
      include: { tags: true }
    });
    If I could do this, it would simplify a lot of code. The actual use case is more complicated than this, but that's the general idea. (The fact that
    resourceId
    is globally unique means that we have the option of ignoring
    resourceType
    , if that helps.) I've read https://www.prisma.io/docs/concepts/components/prisma-schema/relations and Googled "prisma polymorphic relations", but I can't find a "best practice" for handling this situation with the current version of Prisma. Thank you for any insight anyone can provide!
    r
    • 2
    • 5
  • a

    Arfath Tade

    09/15/2021, 3:53 PM
    Hello, I have a model
    Copy code
    model Test {
    id    string
    res   Json
    }
    I want to update multiple rows with different id of the above model I am getting syntax error while running the below query
    Copy code
    prisma.$queryRaw(`UPDATE "TEST" AS T SET
            "res" = a.res
            FROM (VALUES ${updatedData})
            AS a(id, res)
            WHERE a.id = C.id;`);
    updateData have value
    ('1', '[{"name": 'abc'}]'), ('2', '[{"name": 'xyz'}]')
    I tried adding JSONB after every res values and also after a.res but nothing worked can you please help me on this? Error:
    Copy code
    (node:23980) UnhandledPromiseRejectionWarning: Error: 
    Invalid `prisma.queryRaw()` invocation:
      Raw query failed. Code: `42601`. Message: `db error: ERROR: syntax error at or near "m"`
      at cb (/node_modules/@prisma/dist/runtime/index.js:34800:17)
    r
    • 2
    • 2
  • k

    Keenahn Jung

    09/15/2021, 7:02 PM
    Wuz boppin
  • k

    Keenahn Jung

    09/15/2021, 7:04 PM
    I'm working on a library to generate fake data for tests through prisma. I'm taking inspiration from
    factory-girl
    if you're familiar. First roadblock, how do I get a union type of all Prisma models? I see
    Prisma.ModelName
    which is cool. But when I try to do
    Copy code
    type PrismaModel = Prisma[Prisma.ModelName]
  • k

    Keenahn Jung

    09/15/2021, 7:04 PM
    I get "can't use namespace as type"
  • k

    Keenahn Jung

    09/15/2021, 7:04 PM
    wat do
  • j

    Jonas Rothmann

    09/16/2021, 4:34 AM
    I've got a pretty simple question. Is there a way when creating a row that I can set the relation company by doing
    Copy code
    customerId: 12
    instead of
    Copy code
    customer: { connect: { id: 12 } }
    r
    • 2
    • 8
  • a

    Aditya Chadha

    09/16/2021, 5:30 AM
    how do i fix this? Type '{ apikey: string | string[] | undefined; }' is not assignable to type 'UserWhereInput'.
  • a

    Aditya Chadha

    09/16/2021, 5:31 AM
    do i have to declare the types in UserWhereInput somewhere? trying to do a findFirst...
    r
    • 2
    • 1
  • y

    YeonHoPark

    09/16/2021, 6:54 AM
    Is there a way to use the type used in prisma CURD in code ? I want to import UserCreateInput from resolver and use it.
    r
    • 2
    • 2
  • j

    Jonas

    09/16/2021, 8:22 AM
    Is there a way to iterate over all tables in a schema with the prisma client itself? So without using raw queries?
    r
    • 2
    • 16
  • s

    Subho

    09/16/2021, 9:34 AM
    I want to have a check constraint to see if the value of a column in a table is in either one of the column of two tables. For example, value of Party in Payments table should either be in the ID column of Sellers table, or ID column of Purchasers table. Is there any way to enforce this in Prisma schema?
    r
    • 2
    • 1
  • h

    Harsha MV

    09/16/2021, 9:39 AM
    Any good example of dynamic querying when you have a lot of options for sorting, filtering, ordering and pagination.
    Copy code
    // TODO: Adding Dynamic Filters & Sorting
            // Limit - How many records needed
            // Sort - Listing Date, Public Date, Pre-Sale Date
            // Filter - Mint Price Range, Market Place, Blockchain, Project Type, Categories
            // Defaults - Pubic Sale Asc, 5 Days
            // Pagination - rows, dates
    Right now am trying to build multiple where clause to accommodate the above but it doesnt seem to be efficient.
    a
    • 2
    • 1
1...482483484...637Latest