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

optimised seed.ts to avoid seeding of DB problem while setting up the project #424

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dishak
Copy link

@dishak dishak commented May 15, 2024

#313 #221 Addresses the first point in issue #248 (Improve the package management and make sure that seeding and migration don't fail.)

PR Fixes:

  • 1 During setting up the project when seed command is executed sometimes it seeds and sometimes it fails and gives unique constraint problem. (The screenshot attached below of the problem).

screenshot:

Screenshot from 2024-05-15 22-40-52

  • The reason for this being that the stopped container needs to be removed if not removed and restarted then, data is persisted which results in error during seed (failed to seed due to unique constraint)
  • There are 2 open PR Not able to do prisma db seed | help needed #221 bug: Not able to run repo in dev mode. #313 as per suggestions in comments of it, I tried resetting DB and skipping the seed during migrate process but, the issue persisted. Also in comments there was suggestion to use upsert instead of create. So using upsert I refactored the code. Since then, I have never faced issues during seeding process across multiple restarts of the container.
  • The code is refactored in seed.ts to avoid DRY of the code.

Resolves #221 , #313 , Addresses the first point in issue #248

Checklist before requesting a review

  • I have performed a self-review of my code

@dishak
Copy link
Author

dishak commented May 19, 2024

@hkirat , Can you review this.

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 this pull request may close these issues.

Not able to do prisma db seed | help needed
1 participant