https://www.prisma.io/ logo
#orm-help
Title
# orm-help
m

Marius Popa

09/22/2022, 10:01 AM
Hello everyone 🙂 just landed on my first project using Prisma with NextJs, in which I had to add a new field to a table. After the changes, I ran
npx prisma migrate dev
which created the latest version of the db. Locally I could see the new field in the migration, commited and pushed to github and created a PR for the change. When my colleague checked my PR, everything was alright and it was merged. However, our Dev branch is connected to the test server and the db migration seemed to fail for it, the field is not there. I would appreciate a lot if someone has some time to look over the error I drop in the comments of this thread, maybe you encounter the problem too : ) thank you a lot!
✅ 1
Copy code
[2022-09-21 14:54:58] info  - Checking validity of types...
[2022-09-21 14:55:07] Failed to compile.
[2022-09-21 14:55:07] 
[2022-09-21 14:55:07] ./pages/api/demographics.ts:12:61
[2022-09-21 14:55:07] Type error: Type '{ education: any; gender: any; income: any; age: any; soisResultId: any; familyMember: any; }' is not assignable to type '(Without<DemographicsCreateInput, DemographicsUncheckedCreateInput> & DemographicsUncheckedCreateInput) | (Without<...> & DemographicsCreateInput)'.
[2022-09-21 14:55:07]   Object literal may only specify known properties, and 'familyMember' does not exist in type '(Without<DemographicsCreateInput, DemographicsUncheckedCreateInput> & DemographicsUncheckedCreateInput) | (Without<...> & DemographicsCreateInput)'.
[2022-09-21 14:55:07] 
[2022-09-21 14:55:07]   10 |   try {
[2022-09-21 14:55:07]   11 |     const result = await prisma.demographics.create({
[2022-09-21 14:55:07] > 12 |       data: { education, gender, income, age, soisResultId, familyMember },
[2022-09-21 14:55:07]      |                                                             ^
[2022-09-21 14:55:07]   13 |     });
[2022-09-21 14:55:07]   14 |     res.json(result);
[2022-09-21 14:55:07]   15 |   } catch (error) {
[2022-09-21 14:55:07] npm notice
The data is lost most probably in Build Command. Command database cannot be connected on BUILD phase but only on DEPLOY phase... But build depends on database...
j

Jarupong

09/22/2022, 11:07 AM
is there any migration failed?
Could you try to change
npx prisma migrate deploy && npm start
to
npx prisma migrate deploy && npx prisma generate npm start
to ensure that your typescript types is work perfectly
m

Marius Popa

09/22/2022, 11:23 AM
@Jarupong trying now will come with update!
@Jarupong that would not help as deployment fails before that
j

Jarupong

09/22/2022, 11:25 AM
Could you give me full error?
If it's a credential information, we can make private conversation
m

Marius Popa

09/22/2022, 1:04 PM
@Jarupong helped me find a solution for my problem! kudos
prisma rainbow 2
🙌 1
v

Vladi Stevanovic

09/23/2022, 12:13 PM
Awesome job @Jarupong, it's great to know this issue is resolved! ✅
🦜 1
2 Views