question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

EPIC: re-design of `db seed` feature

See original GitHub issue

prisma db seed is currently a Preview feature.

During this phase, we noticed different issues caused by the complexity of the current implementation.

The Migrations Team decided to remove the complexity and make it a lot easier to understand for users and to maintain.

The new implementation is in https://github.com/prisma/prisma/pull/8146

How it will work is that a prisma.seed property in the package.json of your project will be required if you want to use prisma db seed.

The CLI will give examples that can be copy-pasted.

If you are currently using the previous implementation of prisma db seed and upgrade to this new version then it will throw an error with an upgrade help message which should be easy to fix (add prisma.seed to the package.json)

package.json example for a JavaScript project

  "prisma": {
    "seed": "node prisma/seed.js"
  } 

package.json example for a TypeScript project

  "prisma": {
    "seed": "ts-node prisma/seed.ts"
  }

Example of a prisma/seed.js

async function main() {
  await new Promise((resolve) => setTimeout(resolve, 100))
  console.log('Hello from seed.js')
}

main()
  .then(() => console.log('Goodbye from seed.js'))
  .catch((e) => {
    console.error(e)
    process.exit(1)
  })

What needs to done for releasing the “new” db seed:

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:6
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
Jolg42commented, Aug 24, 2021

Hi @tobiasdiez indeed, exiting is not the best in some cases. This is just an example and in this implementation you are free to change it as you need. We removed the “magic” around export and invocation to simplify but that also means you can write a small layer that does that in your project.

4reactions
jasonkuhrtcommented, Aug 13, 2021

Note this will work and is cleaner IMO:

"prisma": {
    "seed": "ts-node prisma/seed"
  }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Seeding your database - Prisma
This guide describes how to seed your database using Prisma Client and Prisma's integrated seeding functionality. Seeding allows you to consistently ...
Read more >
Two approaches to redesigning inpatient care
A new inpatient care model that used multidisciplinary accountable care teams reduced the length of stay and cut additional costs, but did not...
Read more >
Apple Seeds Second Public Beta of iOS 16.1 - MacRumors
Apple says that iOS 16.1 will introduce Live Activities, an interactive notification feature designed to let you keep an eye on things ...
Read more >
Understanding The Epic Cache Database
Features Of The Epic Caché Database · Database Mirroring · Unified Multi-Model Architecture · Powerful Security Features · Cross-Platform ...
Read more >
rs3 player owned house
To fully enjoy the in-game content, an epic or legendary RS3 account is ... So, I recently got 99 Construction and was looking...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found