Before running the command, ensure you have configured your project to support seeding:
- Define the seed script location In your
package.jsonfile, you must specify the command to run your seed script. This command should be located under theprismaproperty.json"prisma": { "seed": "ts-node prisma/seed.ts" // or "node prisma/seed.js" if you are using JavaScript } - Create the seed file Create the actual script in the location specified above (e.g.,
prisma/seed.ts). This script uses Prisma Client to write data to your database. - Run the command Open your terminal and execute:bash
npx prisma db seed
This command will execute the script defined in your
package.json, populating your database with the necessary sample data