Dave Edelhart
08/11/2022, 10:33 PMJeremy Hinegardner
08/11/2022, 11:01 PMMatt Mueller (Prisma Client PM)
@@unique(fields: ["firstName", "lastName"])
=> leads to index and client API being firstName_lastName. Not great.
• @@unique(fields: ["firstName", "lastName"], name: "fullName")
=> index is still named firstName_lastName, client API is fullName.
• @@unique(fields: ["firstName", "lastName"], name: "fullName", map: "fullName")
=> index name and client API are fullName.Matt Mueller (Prisma Client PM)
You should be able to define the where fields without having to introspect the index structure.In this case, we need some way to know that findUnique only takes a first name and last name. Since the index is decoupled from the SQL query, I'm not even sure knowing the name of the index matters much, as long as you have something like:
@@unique(fields: ["firstName", "lastName"], name: "fullName")
in your schema. The client will happily generate a client.
In practice, you'd probably want to either have an introspection or migration loop going to keep the Prisma Schema in sync with the DB.humblecoder
08/12/2022, 6:47 AMmode:'insensitive'
. . . however, the index-esque nature of Prisma doesn’t seem to accept those params in the context of index constraints. What am I missing? 🤔Nurul
08/30/2022, 12:46 PMPrisma doesn’t seem to accept those params in the context of index constraints.Can you please share the query and your model on what you are trying to achieve so that we can have a look?