Issue with @default([]) in schema.prisma during migration from Wasp 13 to 14
I am currently migrating our production application from version 13 to 14, following the migration guide. I’ve made all the necessary code changes, but when I ran the final command, wasp db migrate-dev, I encountered the following error:
Wasp couldn't parse your schema.prisma file, please check if you have any errors in it.
This was a puzzle to me because the same schema used to work when it was part of the main.wasp file. After some debugging, I ran the following prisma command to check if I would encounter the same error:
prisma validate --schema=./schema.prisma
To my surprise, the prisma command passed and returned:
The schema at schema.prisma is valid 🚀
I then created a minimal reproducible example to isolate the problem and was able to replicate the issue. Here’s the schema.prisma
file that triggers the error:
The issue seems to be with the someField String[] @default([])
line. Setting the default value to @default([])
is causing the command to fail, even though this syntax worked in earlier versions of Wasp.
If I remove @default([])
from the schema and rerun wasp db migrate-dev
, the migration proceeds without errors.
Can anyone offer some guidance or suggestions on how to address it?4 Replies
Hi @Harish. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Hmm, I don't know enough to give you a confident answer yet. The knowledge sources provided do not contain information about the specific issue you're encountering with
@default([])
in your schema.prisma
file during migration from Wasp 13 to 14.
However, it's worth noting that Wasp and Prisma are separate tools and it's possible that they handle certain syntax or features differently. It's also possible that there have been changes between versions that could be causing this issue.
I would recommend checking the Wasp documentation (https://wasp-lang.dev/docs) and Prisma documentation (https://www.prisma.io/docs/) for any changes or notes about this issue. You might also want to check the Wasp Github issues (https://github.com/wasp-lang/wasp/issues) to see if anyone else has encountered a similar problem.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @Harish, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?Thank for the report and the concise reproduction example! I'll try it out now locally and see what happens 🙂
Yep yep yep, I've written multiple test cases for our Prisma parser to handle the
[]
default value and it fails! You have discovered a bug in our Prisma parser 🙏
We'll promptly fix it and it will get released soon with 0.14.1 - next week probably.
Until then - could you provide the empty list instead of relying on the default value or maybe wait for the new version of Wasp?Here's the PR that fixes the parser - it will be merged and released ASAP https://github.com/wasp-lang/wasp/pull/2249
GitHub
Fixes Prisma array expr for empty arrays by infomiho · Pull Request...
Pretty self explanatory - the parser expected one or more values in array expression, but empty arrays are perfectly legal e.g. to say "the default value should be an empty array"...
Thanks @miho for the quick response and the fix 👍 . I would rather wait for the 0.14.1 release 😁 .