Hey Prisma folks :wave:! I wanted some help with a...
# orm-help
k
Hey Prisma folks 👋! I wanted some help with an issue that I'm facing with Prisma client. I posted a discussion here about it, but haven't received any responses yet and since this is a blocker for me I would really appreciate some help 🙏 - https://github.com/prisma/prisma/discussions/13423. To reiterate, I renamed a column in my database, ran
npx prisma db pull
and
npx prisma generate
and now I cannot create any records due to an error
The column new does not exist
There was no column
new
to begin with. I don't use
prisma migrate
the database is modified manually by the team, and it makes sense to update the Prisma schema as per the database. This is only happening with this one table. Any suggestions on what could be wrong? Thank you!
r
Hi @Kavita Nambissan - does your
prisma.schema
file get updated with the new column?
k
Yes, the schema updates correctly with the renamed column.
The column name went from
longtude
to
longitude
It was a typo fix. Not sure where
new
comes in..
r
and the issue is happening on the
npx prisma generate
?
k
No,
npx generate
works fine. When I try to run a
prisma.affectedtable.create
it fails with this error.
r
What does the
"AffectedTable"CreateInput
type look like in your generated prisma
index.d.ts
file?
k
I'm not using Typescript so no generated prisma
index.d.ts
file.. 🙂
r
What does your
create
look like?
in your code
k
Not sure if this is what you meant, but I logged the input received by the
create
There is no column in there by the name
new
I use a util method to map my schema names to DB names, so the final input is specific.
Copy code
await prisma.table_name.create({
      data: finalData,   // finalData is just a transformed object with columns names to values
      include: {
       ...someIncludeFields
      },
    });
The input request
Copy code
input CreateEntryInput {
    status: String = "active"
    email: EmailScalar!
    mobilePhone: String
    officePhone: String
    addressLine1: String
    city: String
    state: String
    zipCode: String
    companyName: String!
    serviceIds: [Int!]
    contactId: Int
  }
All of this was working before I changed the column name..
r
Yeah - I was wondering f there was a "new" somewhere in the
finalData
..
k
No I checked..
I tried deleting the column entirely (updating schema) and then adding it back (updated schema) failed for each case
r
Could you add a stripped down use case to your github discussion - that could help prisma support people try find out what's wrong ..
it seems like everything should be working fine ..
k
Yeah, I cannot understand why this would cause an error..it's not some advanced use case.. Sure, I'll add more details to the discussion 👍, thanks!