Best practice for adding properties to User entity?

I'm looking at adding a property called isCreator to the existing user entity that comes with OpenSaaS, but when I do it and attempt to migrate the db I get this error
[ Wasp ] ext-src/server/scripts/usersSeed.ts(10,9): error TS2741: Property 'isCreator' 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; email: string; username: string; createdAt: Date; lastActiveTimestamp: Date; isAdmin: boolean; stripeId: string; checkoutSessionId: string; subscriptionTier: string; ... 4 more ...; isCreator: boolean; }, unknown> & {}, "id">'.
[ Wasp ] ext-src/server/scripts/usersSeed.ts(10,9): error TS2741: Property 'isCreator' 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; email: string; username: string; createdAt: Date; lastActiveTimestamp: Date; isAdmin: boolean; stripeId: string; checkoutSessionId: string; subscriptionTier: string; ... 4 more ...; isCreator: boolean; }, unknown> & {}, "id">'.
I'm sure it's something I've done wrong as I am not to familiar with prisma!
4 Replies
kapa.ai
kapa.ai8mo ago
Hi @CamBlackwood. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the error message you provided, it seems like you've added the isCreator property to your User entity in your Prisma schema, but you haven't updated the seeding script (usersSeed.ts) to include this new property when creating new User records. To fix this, you'll need to update your usersSeed.ts file to include the isCreator property when creating new User records. Here's an example of how you might do this:
// In usersSeed.ts
const users = [
{
username: 'example',
createdAt: new Date(),
lastActiveTimestamp: new Date(),
isAdmin: false,
stripeId: 'stripeId',
sendEmail: false,
subscriptionStatus: 'status',
datePaid: new Date(),
credits: 0,
checkoutSessionId: null,
subscriptionTier: 'tierId',
isCreator: false, // Add this line
},
// ...other users
];
// In usersSeed.ts
const users = [
{
username: 'example',
createdAt: new Date(),
lastActiveTimestamp: new Date(),
isAdmin: false,
stripeId: 'stripeId',
sendEmail: false,
subscriptionStatus: 'status',
datePaid: new Date(),
credits: 0,
checkoutSessionId: null,
subscriptionTier: 'tierId',
isCreator: false, // Add this line
},
// ...other users
];
Remember to replace the example values with actual values that make sense for your application. For more information on how to define entities in Wasp, you can refer to the official Wasp documentation (https://wasp-lang.dev/docs/data-model/entities). This guide explains how to use the Prisma Schema Language (PSL) to define your data models, which is what you'll need to do to add the isCreator property to your User entity. If you're still having trouble, don't hesitate to ask for more help! ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @CamBlackwood, 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?
CamBlackwood
CamBlackwoodOP8mo ago
worked like a charm, thank you bot ❤️
MEE6
MEE68mo ago
Wohooo @CamBlackwood, you just became a Waspeteer level 2!
miho
miho8mo ago
Good bot 😄
Want results from more Discord servers?
Add your server