Error Running Migrations
When I run
wasp db migrate-dev
it returns the following error:
This seems to be pointing to some type definition, but I can't find it.8 Replies
Hi @terver. 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 error message you're seeing is a TypeScript error, indicating that the 'consultantId' property is missing in a certain type. This could be due to a variety of reasons, such as a missing field in your Prisma schema or a mismatch between your Prisma schema and your TypeScript types.
However, without more specific information about your Wasp project and its configuration, it's hard to provide a definitive solution. I would recommend checking your Prisma schema and TypeScript types to ensure they align correctly.
For more information on how to work with Prisma in Wasp, you can check out the Wasp documentation (https://wasp-lang.dev/docs/migrate-from-0-11-to-0-12).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @terver, 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?
@kapa.ai How are types defined from entities?
Let me check the knowledge base for you. One moment! :books:
----------------------
In Wasp, types are defined from entities using the Prisma Schema Language (PSL). Each entity declaration in Wasp corresponds 1-to-1 to Prisma's data model. Here's an example of how you could define an Entity that represents a Task:
In this declaration:
-
entity Task
tells Wasp to define an Entity (i.e., database model) called Task
. Wasp automatically creates a table called tasks
.
- {=psl ... psl=}
is where Wasp treats everything that comes between the two psl
tags as PSL (Prisma Schema Language).
The PSL definition tells Wasp to create a table for storing Tasks where each task has three fields (i.e., the tasks
table has three columns):
- id
- An integer value serving as a primary key. The database automatically generates it by incrementing the previously generated id
.
- description
- A string value for storing the task's description.
- isDone
- A boolean value indicating the task's completion status. If you don't set it when creating a new task, the database sets it to false
by default.
For more information, you can refer to the Wasp documentation on entities (https://wasp-lang.dev/docs/data-model/entities#defining-an-entity).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @terver, 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?It was a public holiday today and most of the team was off, we'll get back to you tomorrow 🙂
Hey @terver , how did you make this app? At which point did it stop working? Sounds like you might have a Query which is returning some User but what you are returning is missing some fields -> but could you provide more context on this error? Maybe some more logs, piece of code that this might be connect with, anything?
I think I'm in the same situation. Trying to perform a migration where I add an optional field to
User
, but since there already exist users without the new property in the DB the migration fails. For example:
Migrating from:
To:
Fails with
I'm not sure what to do 🤔 any idea @kapa.ai ?Hm but you are not getting a migration error actually, you are getting a Typescript error. It is peculiar that this type you are dealing with has
myField: string
shown as required, and email also.
This TS error: can you show more info related to it? File path / line number?
Also, can you describe in detail how you got into this state? So first you had everything working with a specific DB schema: pls share entity User at that point. THen you did a change and run wasp db migrate-dev
possibly? Or at which moment did you get this error?