DB seeding

Will there be any plans to add a db seeding template to the T3 stack? Perhaps a script file that users can edit and run a db seed script to populate the database? Thanks!
4 Replies
bigsexy
bigsexy3y ago
doubt it. that would be highly dependant on the data you are using. and i dont think ct3a wants to be a "demo" starter app with some random pre initialized data. im assuming youre using prisma. Its pretty easy to seed, you just make seed.ts file in side of your ./src/prisma/ directory. in there you can load up some json, or make some request to an external api, to get some intial data, and then just use the prisma client to insert said data into your db. the seed.ts script will be ran everytime you prima migrate dev alternatively you can manually run it with prisma db seed iirc. I think prisma automatically uses any file called seed. nvm you have you to add it into package.json.
{
"name": foobar
...
"scripts": {...}
"prisma": {
"seed": "ts-node prisma/seed.ts"
},
...
}
{
"name": foobar
...
"scripts": {...}
"prisma": {
"seed": "ts-node prisma/seed.ts"
},
...
}
bigsexy
bigsexy3y ago
Prisma
Seeding your database
Learn how to seed your database using Prisma's integrated seeding functionality and Prisma Client
karlosos
karlosos3y ago
More specifically:
"prisma": {
"seed": "ts-node --compiler-options {\"module\":\"CommonJS\"} prisma/seed.ts"
},
"prisma": {
"seed": "ts-node --compiler-options {\"module\":\"CommonJS\"} prisma/seed.ts"
},
as regular ts-node won't work for t3 app.
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server