W
Wasp-lang•6mo ago
terver

Error Running Migrations

When I run wasp db migrate-dev it returns the following error:
error TS2741: Property 'consultantId' is missing in type '{ email: string; username: string; createdAt: Date; lastActiveTimestamp: Date; isAdmin: false; stripeId: string; sendEmail: false; subscriptionStatus: string; datePaid: Date; credits: number; checkoutSessionId: null; subscriptionTier: TierIds; }' but required in type 'Omit<GetResult<{ id: number; createdAt: Date; consultantId: string; email: string; username: string; lastActiveTimestamp: Date; isAdmin: boolean; stripeId: string; checkoutSessionId: string; ... 4 more ...; credits: number; }, unknown> & {}, "id">'.
error TS2741: Property 'consultantId' is missing in type '{ email: string; username: string; createdAt: Date; lastActiveTimestamp: Date; isAdmin: false; stripeId: string; sendEmail: false; subscriptionStatus: string; datePaid: Date; credits: number; checkoutSessionId: null; subscriptionTier: TierIds; }' but required in type 'Omit<GetResult<{ id: number; createdAt: Date; consultantId: string; email: string; username: string; lastActiveTimestamp: Date; isAdmin: boolean; stripeId: string; checkoutSessionId: string; ... 4 more ...; credits: number; }, unknown> & {}, "id">'.
This seems to be pointing to some type definition, but I can't find it.
8 Replies
kapa.ai
kapa.ai•6mo ago
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?
terver
terverOP•6mo ago
@kapa.ai How are types defined from entities?
kapa.ai
kapa.ai•6mo ago
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:
entity Task {=psl
id Int @id @default(autoincrement())
description String
isDone Boolean @default(false)
psl=}
entity Task {=psl
id Int @id @default(autoincrement())
description String
isDone Boolean @default(false)
psl=}
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?
miho
miho•6mo ago
It was a public holiday today and most of the team was off, we'll get back to you tomorrow 🙂
martinsos
martinsos•6mo ago
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?
JakeLoew
JakeLoew•5mo ago
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:
entity User {=psl
id Int @id @default(autoincrement())
email String? @unique
psl=}
entity User {=psl
id Int @id @default(autoincrement())
email String? @unique
psl=}
To:
entity User {=psl
id Int @id @default(autoincrement())
email String? @unique
myField String?
psl=}
entity User {=psl
id Int @id @default(autoincrement())
email String? @unique
myField String?
psl=}
Fails with
error TS2741: Property 'myField' is missing in type '{ email: string; }' but required in type 'Omit<GetResult<{ id: number; email: string; myField: string; }, unknown> & {}, "id">'.
error TS2741: Property 'myField' is missing in type '{ email: string; }' but required in type 'Omit<GetResult<{ id: number; email: string; myField: string; }, unknown> & {}, "id">'.
I'm not sure what to do 🤔 any idea @kapa.ai ?
martinsos
martinsos•5mo ago
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?
Want results from more Discord servers?
Add your server