Prisma1: Additional seeding workflows

Created on 7 Jan 2018  ·  13Comments  ·  Source: prisma/prisma1

  • [ ] prisma reset should reset the database and initiate seeding if a seed property is present (optionally provide --no-seed flag)
  • [ ] prisma import should accept a .graphql file for seeding
  • [x] prisma seed (optional): Run seed according to seed property in prisma.yml. This would be convenient, but developers needs to make sure to run prisma reset before (if she so wishes).
  • [ ] more ideas here: https://github.com/graphcool/prisma/issues/1181

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

prisma seed --reset
statustale

Most helpful comment

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

All 13 comments

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?

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

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!

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sorenbs picture sorenbs  ·  43Comments

sorenbs picture sorenbs  ·  48Comments

marktani picture marktani  ·  71Comments

pantharshit00 picture pantharshit00  ·  49Comments

marktani picture marktani  ·  62Comments