W
Waspβ€’8mo ago
BradMcA

Error while seeding DB any ideas how to solve? #p2021

[ Db ] Environment variables loaded from .env [ Db ] Running seed command npm run db-seed ... [ Db ] [ Db ] > [email protected] db-seed [ Db ] > npm run bundle && node --enable-source-maps -r dotenv/config bundle/dbSeed.js [ Db ] [ Db ] [ Db ] > [email protected] bundle [ Db ] > rollup --config --silent [ Db ] [ Db ] Running seed: devSeedUsers [ Db !] PrismaClientKnownRequestError: [ Db !] Invalid prismaClient.user.create() invocation in [ Db !] /mnt/c/users/brad/xyz/app/src/server/scripts/usersSeed.ts:41:33 [ Db !] [ Db !] 38 try { [ Db !] 39 await Promise.all( [ Db !] 40 USERS.map(async (user) => { [ Db !] β†’ 41 await prismaClient.user.create( [ Db !] The table public.User does not exist in the current database. [ Db !] at Rn.handleRequestError (/mnt/c/users/brad/xyz/app/node_modules/@prisma/client/runtime/library.js:174:7325) [ Db !] at Rn.handleAndLogRequestError (/mnt/c/users/brad/xyz/app/node_modules/@prisma/client/runtime/library.js:174:6754) [ Db !] at Rn.request (/mnt/c/users/brad/xyz/app/node_modules/@prisma/client/runtime/library.js:174:6344) [ Db !] at <anonymous> (/mnt/c/users/brad/xyz/app/src/server/scripts/usersSeed.ts:41:15) [ Db !] at async Promise.all (index 4) [ Db !] at Object.devSeedUsers (/mnt/c/users/brad/xyz/app/src/server/scripts/usersSeed.ts:39:5) [ Db !] at main (/mnt/c/users/brad/xyz/app/.wasp/out/server/src/dbSeed.ts:23:10) { [ Db !] code: 'P2021', [ Db !] clientVersion: '4.16.2', [ Db !] meta: { table: 'public.User' } [ Db !] } [ Db ] [ Db ] 🌱 The seed command has been executed. βœ… --- Database seeded successfully! ----------------------------------------------
4 Replies
kapa.ai
kapa.aiβ€’8mo ago
Hi @BradMcA. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The error message indicates that the public.User table does not exist in your current database. This is likely because the database schema has not been properly initialized or migrated before running the seed command. Here are some steps you can take to resolve this issue: 1. Ensure that your Prisma schema (schema.prisma) is correctly defined and includes the User model. 2. Run the Prisma migration command to update your database schema:
npx prisma migrate dev --preview-feature

npx prisma migrate dev --preview-feature

This command will apply the migrations to your database, creating the necessary tables. 3. After successfully running the migrations, try running the seed command again:
wasp db seed <seed-name>

wasp db seed <seed-name>

Replace <seed-name> with the name of your seed function. If you've only defined a single seed function, you can simply run wasp db seed. Please note that these instructions are based on the assumption that you are using Prisma as your database client and that the error is due to a missing table in your database. If the problem persists, it might be due to other issues not covered by the provided knowledge sources. For more information on seeding the database in Wasp, you can refer to the official documentation (https://wasp-lang.dev/docs/data-model/backends#cli-commands-for-seeding-the-database). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @BradMcA, 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?
martinsos
martinsosβ€’8mo ago
Have you run wasp db migrate-dev first? It says that User database doesn't exist in your database, so if you do migration, that should set up the tables / schemas.
BradMcA
BradMcAOPβ€’8mo ago
That solved the issue and unblocked me thank you @martinsos
MEE6
MEE6β€’8mo ago
Wohooo @BradMcA, you just became a Waspeteer level 1!
Want results from more Discord servers?
Add your server