Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup script runs db seed script twice when using sqlite. #60

Closed
earlofurl opened this issue Apr 17, 2022 · 2 comments · Fixed by #109
Closed

Setup script runs db seed script twice when using sqlite. #60

earlofurl opened this issue Apr 17, 2022 · 2 comments · Fixed by #109

Comments

@earlofurl
Copy link

Have you experienced this bug with the latest version of the template?

Yes

Steps to Reproduce

  1. Create fresh indie stack project.
  2. Run npm run setup

Expected Behavior

  1. prisma migrate dev runs, syncing database and generating client
  2. when migrating is complete, prisma db seed runs, seeding the database according to seed.ts

Actual Behavior

  1. prisma migrate dev runs, and in addition to syncing db and generating client, it also runs the seed script.
  2. prisma db seed runs, and fails when it hits a unique constraint because the db has already been seeded
    remixSeedSqliteIssue.txt
    .
@earlofurl
Copy link
Author

Discord user cev#2144 says that the setup command works as intended when using postgresql, but runs twice when using sqlite.

It is unclear from the Prisma Docs which behavior is intended.

migrate dev says it will generate artifacts, but does not say it's supposed to run the seed command.
The next section, migrate reset, does explicitly state that it runs the seed command.

In my case, using sqlite, the problem is effectively fixed by replacing "setup": "prisma migrate dev" && prisma db seed with "setup": "prisma migrate dev"

However, it sounds like this would not automatically seed the db for users who switch to postgresql.

@mcansh
Copy link
Contributor

mcansh commented Jun 20, 2022

this doesn't appear to happen in prisma 3.15.2

nope never mind it does, we can update this script as seeding is ran during prisma migrate dev https://github.com/prisma/prisma/blob/main/packages/migrate/src/commands/MigrateDev.ts#L325

plus we ship a migration in this template so really we should be using prisma migrate deploy

@mcansh mcansh linked a pull request Jun 20, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants