Closed marktani closed 5 years ago
Yes, I just used prisma reset
expecting it will seed data from seed.graphql
only to find out it didn't. I think it doesn't make much sense to have seed file there as a part of initial boilerplate while its modification doesn't matter as it cannot be used anymore.
I can imagine seeding support as a good practice for running automated E2E tests.
@FredyC
What's so hard about
prisma delete prisma deploy
It works fine for me.
@gihrig It's not about hard, but about some sort of comfort and I bet it's even faster to just reset data than destroy and recreate the whole service. For automated tests having extra seconds does matter, especially if you need to reset several times to ensure a clean slate.
Really looking forward to this feature - destroying services each time for the sake of resetting seeds is overkill.
We added prisma seed
in 1.7.0
:
prisma seed # seed data according to `seed` property in `prisma.yml`
prisma seed --reset # reset service before seeding.
@marktani great news on prisma seed
would it be worth updating the documentation to show that this is now possible?
I'm starting a new project for automating the seeding on multiples db with javascript and knex.js, please have a look at this and let me hear your recommends, thanks
here is a code example:
//creating and seeding process
ks.createAndSeed(userTableModel, 10).then(() => {
//creating the table automatically & seeding ...
ks.createAndSeed_close(roleTableModel, 10, (table) => { //closes the connection after process
//creating the table with knex.js fn & and seeding ...
table.increments(),
table.string('name'),
table.string('category'),
table.timestamps(true, true)
}).then(()) =>{
//do something here...
}
})
Thanks for sharing @2rhop, can you elaborate how this is relevant for Prisma? 🙂
Is graphcool cli going to support this too?
I'm using graphcool-framework and not prisma, and I need to import a .graphql file for seed data. Should I open a new issue in the graphcool-framework repository?
If like me you wanted to clear the db and then re-seed:
prisma reset
y
prisma seed
It was mentioned that we can supply a script for seeding, does that mean it is just a hook, and no method from prisma is injected?
@marktani It's not relevant. He's advertising his OSS (with logos and self-thumbs-up and everything)... 🤦♂️
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 10 days if no further activity occurs. Thank you for your contributions.
prisma reset
should reset the database and initiate seeding if aseed
property is present (optionally provide--no-seed
flag)prisma import
should accept a.graphql
file for seedingprisma seed
(optional): Run seed according toseed
property inprisma.yml
. This would be convenient, but developers needs to make sure to runprisma reset
before (if she so wishes).Right now, the best workflow to "start from scratch" + seeding is this: