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

    Austin Zentz

    02/03/2022, 6:48 PM
    as in, why go through the hassle of creating/running the migration?
  • n

    Nick B

    02/03/2022, 6:50 PM
    It could just be my ignorance of what's possible, but what I've run into is the inability to create a new column in a table with existing data without losing all of that data. I get an error message of something like.... Added the required column without a default value. This is not possible if the table is not empty
  • n

    Nick B

    02/03/2022, 6:51 PM
    I'm trying to figure out what the best route to take is... but I'm also trying to understand it at - I guess a philosophical level as well, if that makes sense
  • a

    Austin Zentz

    02/03/2022, 6:51 PM
    Ah, gotcha -- I'm not familiar with phpMyAdmin, but in Prisma columns are required by default. You could just switch a new column to be optional at the database level and avoid that error message.
  • n

    Nick B

    02/03/2022, 6:51 PM
    I understand there is a way to seed a DB, which is fine, but also seems cumbersome as opposed to just adding a damn column
  • n

    Nick B

    02/03/2022, 6:52 PM
    ah, interesting
  • a

    Austin Zentz

    02/03/2022, 6:52 PM
    (i think you could do something similar by setting a default value on a required field, but i'm not as sure there)
  • a

    Austin Zentz

    02/03/2022, 6:53 PM
    prisma migrations are a little funky, and fairly new, though -- they are more likely to want to trash the whole database than other offerings when they spot some migration drift
  • a

    Austin Zentz

    02/03/2022, 6:54 PM
    i take it as part of the whole package w/ prisma, which i really like overall. but you could use some other migration tool, or skip migrations entirely and just add database columns a la phpMyAdmin. You'd just have to keep up with your Prisma schema separately.
  • n

    Nick B

    02/03/2022, 6:56 PM
    I gotcha - thanks for that. This is where my ignorance kicks in for sure. I'm not 100% which direction to go. Oh well, onwards!
    👍 1
  • r

    Ryan Delaney

    02/03/2022, 7:02 PM
    Hey everyone! Quick question: is it possible to cancel an in-flight query? Context: We’d like to cancel expensive queries if the HTTP request for the data is cancelled as well.
    n
    • 2
    • 1
  • s

    Shaul Zuarets

    02/03/2022, 8:00 PM
    Hi all, I’m new to Prisma and love it :) (used to work with Sequelize). I wanted to add multi-tenancy support (mainly for SaaS products) using a shared database strategy, meaning, one database and on each table, a tenant ID column. The idea is that from a developer point of view, there is no need to worry about adding a where clause to each CRUD operation, we will do it for him/her. As I see it, there were 3 challenges: 1. Extracting the tenant id from a request/message - I’ve added an express middleware for that. 2. Storing the tenant id in a way switching context in an async operations won’t affect it - solve it with async local storage. 3. Making sure each database query is with a
    where
    clause and with the proper tenant ID - I’ve added a Prisma middleware for that. I’ve wrote (me and @yakirgot) a new npm package for all of it here, and the code is here. I have two questions: 1. in different languages, I used to work with database hooks or scope to get this functionality and I wonder if middleware is the right approach in prisma. Am I missing anything? 2. My
    where
    clause validation is pretty simple and straightforward, I would love to get your opinion on it. PS, you are all more than welcome to contribute, there is still much work needed :) Thanks in advance, Shaul
    a
    • 2
    • 3
  • a

    Austin Zentz

    02/03/2022, 8:09 PM
    impressive project!
    ❤️ 1
  • g

    Greger gregerson

    02/03/2022, 8:55 PM
    Quick question: If I got 2 models (User & Fruit) and I want Users to be able to share what Fruit they like (i.e. User1 likes Apples User2 likes Apples and Banana), how exactly would you do so? I'm unsure if it's an One-to-Many or Many-to-Many I need here
    s
    • 2
    • 4
  • a

    Alex Vilchis

    02/03/2022, 9:12 PM
    Hi, guys, is full text search broken on MySQL? All my queries seem to be failing even with previewFeatures on 😕
    😕 1
    a
    n
    • 3
    • 9
  • l

    Levy Barbosa

    02/03/2022, 9:46 PM
    Hey guys, is there any way to use raw sql functions in only one parameter of a "where"? Basically, I have this string field, and I want to filter the rows where this field is equal to some certain value, but the thing is, that value can come with some padded zeroes, but I still want them, like, I also want rows with "0012345" when looking for "12345", is that possible?
    n
    • 2
    • 1
  • i

    ItsMeAlfie0

    02/04/2022, 8:12 AM
    Hey, I'm getting a weird error and I just can't figure out why. “TypeError: Cannot read properties of undefined (reading 'accounts')” Can I get some help?
    m
    • 2
    • 5
  • a

    ANUP KUMAR

    02/04/2022, 8:42 AM
    Have anyone used full text search functionality of Prisma? Not sure what going wrong, but the search query is not using index at all. Any detailed example will be helpful.
    n
    • 2
    • 1
  • k

    Kay Khan

    02/04/2022, 9:43 AM
    Is it possible to rename this join
    image_imageToperson_profile_image_id
    Copy code
    const data: any = await prisma.mview_entity_inheritance.findMany({
            include: {
                person: { include: { image_imageToperson_profile_image_id: true } },
            },
            where: { service_id: { in: serviceIds } },
        });
    s
    • 2
    • 11
  • k

    Kay Khan

    02/04/2022, 10:16 AM
    Hi friends i am trying to query a
    view
    using prisma with
    queryraw
    . I want to select multiple rows using the sql "IN" however i get the error:
    Copy code
    Raw query failed. Code: `N/A`. Message: `Arrays are not supported in MySQL.`
    Copy code
    const entityIds = ["9704cad8-c69e-4e85-9f12-e9ea6055d140"];
    
    const socials = await prisma.$queryRawUnsafe("SELECT * FROM view_quick_reach WHERE brand_id IN (?)", entityIds);
  • k

    Kay Khan

    02/04/2022, 10:17 AM
    Ah i found the answer https://www.prisma.io/docs/concepts/components/prisma-client/raw-database-access#tagged-template-helpers
    💯 1
  • o

    Oksana Danshyna

    02/04/2022, 10:19 AM
    👋 Hi everyone! 🎉 We launched our new page with all the upcoming events. Now you can easily follow all the updates and check the content from the previous ones. ➡️ Check the list and RSVP: https://www.prisma.io/events
    🙌 5
    💯 3
    🙌🏽 1
    👏🏽 1
    👏 2
    🦜 3
    prisma rainbow 6
    💥 3
    🤩 4
  • a

    Alex Vilchis

    02/04/2022, 3:26 PM
    Hello! Is it a good idea to delete my
    migrations/
    directory and create an entirely new migration history? My
    migrate dev
    command is taking too long with 116 migrations 😕
    t
    a
    • 3
    • 4
  • j

    Jonathan Marbutt

    02/04/2022, 5:44 PM
    If you are wanting to use postgres inherited tables, what is the best way to manage that with prisma migrate? or if you are using that does that mean you can’t really use prisma migrate?
    n
    • 2
    • 4
  • r

    Richard Kaufman-López

    02/04/2022, 8:31 PM
    Hi everyone. Does
    ///
    comments work on enum values? https://www.prisma.io/docs/concepts/components/prisma-schema#comments
    n
    • 2
    • 3
  • n

    Nadeshi Kon

    02/05/2022, 5:02 AM
    Hi, is there a channel dedicated to nexus-prisma
    y
    • 2
    • 1
  • b

    Brook MG

    02/05/2022, 11:15 AM
    Guys anyone know a workaround for this? https://github.com/prisma/prisma/issues/5019 If it's currently being implemented thou, that would be great
  • c

    Chris

    02/05/2022, 11:32 AM
    Copy code
    const data = await prisma.$queryRaw`SELECT * FROM Series WHERE name LIKE '%${series}%';`
    Copy code
    prisma:info Starting a sqlite pool with 17 connections.
    prisma:query SELECT * FROM Series WHERE name LIKE '%?%';
    /Users/chriscoughlan/Code/longbox/backend/node_modules/@prisma/client/runtime/index.js:38703
              throw new PrismaClientKnownRequestError(message, e.code, this.prisma._clientVersion, e.meta);
                    ^
    PrismaClientKnownRequestError: 
    Invalid `prisma.queryRaw()` invocation:
    
    
      Raw query failed. Code: `N/A`. Message: `N/A`
        at cb (/Users/chriscoughlan/Code/longbox/backend/node_modules/@prisma/client/runtime/index.js:38703:17)
        at async Proxy._request (/Users/chriscoughlan/Code/longbox/backend/node_modules/@prisma/client/runtime/index.js:40853:18) {
      code: 'P2010',
      clientVersion: '3.9.1',
      meta: { code: 'N/A', message: 'N/A' }
    }
    Any ideas?
    t
    • 2
    • 1
  • c

    Chris

    02/05/2022, 11:33 AM
    Copy code
    const data = await prisma.$queryRaw`SELECT * FROM Series WHERE name = ${series};`
    Works fine
  • a

    Aytaç Ünal

    02/05/2022, 3:01 PM
    Anyone can help me ?
1...541542543...637Latest