daily-code
daily-code copied to clipboard
Fix TypeScript compilation error in seed script
Description: This pull request resolves a TypeScript compilation error encountered while running the seed script. The error occurred due to missing properties in the seed data object passed to Prisma.
Changes:
Added missing sortingOrder property to the seed data object to align with the requirements of the TrackProblems model in Prisma. Details:
Updated the prisma/seed.ts file to include the sortingOrder property in the seed data object. Verified that the TypeScript compilation error is resolved and the seed script runs successfully.
before -
after -
Simulated seeding without the sortingOrder property to confirm the error message. Expected Error Message (if sortingOrder is omitted during seeding):
prisma/seed.ts:10:9 - error TS2322: Type '{ problem: { create: { title: string; description: string; notionDocId: string; type: "Blog"; }; }; }' is not assignable to type '(Without<TrackProblemsCreateWithoutTrackInput, TrackProblemsUncheckedCreateWithoutTrackInput> & TrackProblemsUncheckedCreateWithoutTrackInput) | (Without<...> & TrackProblemsCreateWithoutTrackInput) | TrackProblemsCreateWithoutTrackInput[] | TrackProblemsUncheckedCreateWithoutTrackInput[] | undefined'.
Type '{ problem: { create: { title: string; description: string; notionDocId: string; type: "Blog"; }; }; }' is not assignable to type 'Without<TrackProblemsUncheckedCreateWithoutTrackInput, TrackProblemsCreateWithoutTrackInput> & TrackProblemsCreateWithoutTrackInput'.
Property 'sortingOrder' is missing in type '{ problem: { create: { title: string; description: string; notionDocId: string; type: "Blog"; }; }; }' but required in type 'TrackProblemsCreateWithoutTrackInput'.
I think that in the future, we should not need the seed file, itself. Although you could have also copied migrate.ts to seed.ts to make the seed work just fine in your local dev environment.
I think that in the future, we should not need the seed file, itself. Although you could have also copied migrate.ts to seed.ts to make the seed work just fine in your local dev environment.
Having a seed file helps newcomers understand seed how we start with data in our project and keeps everyone's development environments consistent