prisma / prisma1

💾 Database Tools incl. ORM, Migrations and Admin UI (Postgres, MySQL & MongoDB) [deprecated]
https://v1.prisma.io/docs/
Apache License 2.0
16.54k stars 861 forks source link

Additional seeding workflows #1536

Closed marktani closed 5 years ago

marktani commented 6 years ago

Right now, the best workflow to "start from scratch" + seeding is this:

prisma seed --reset
danielkcz commented 6 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.

gihrig commented 6 years ago

@FredyC

What's so hard about

prisma delete prisma deploy

It works fine for me.

danielkcz commented 6 years ago

@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.

steve-a-jones commented 6 years ago

Really looking forward to this feature - destroying services each time for the sake of resetting seeds is overkill.

marktani commented 6 years ago

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.
jjaybrown commented 6 years ago

@marktani great news on prisma seed would it be worth updating the documentation to show that this is now possible?

https://www.prisma.io/docs/reference/service-configuration/prisma.yml/yaml-structure-ufeshusai8#seed-(optional)

renerpdev commented 6 years ago

Hello

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...
  }
})

One code to seed them all!

marktani commented 6 years ago

Thanks for sharing @2rhop, can you elaborate how this is relevant for Prisma? 🙂

DamianPereira commented 6 years ago

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?

jasonleonhard commented 6 years ago

If like me you wanted to clear the db and then re-seed:

prisma reset
y
prisma seed
viztor commented 6 years ago

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?

corysimmons commented 6 years ago

@marktani It's not relevant. He's advertising his OSS (with logos and self-thumbs-up and everything)... 🤦‍♂️

stale[bot] commented 5 years ago

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.