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

Seeding script #12

Merged
merged 71 commits into from
Sep 28, 2024
Merged

Seeding script #12

merged 71 commits into from
Sep 28, 2024

Conversation

VJagiasi
Copy link
Collaborator

@VJagiasi VJagiasi commented Jun 25, 2024

Notion ticket link

Create Seeding Script

Implementation description

  • Added the seeding script using snaplet to implement seeding and used faker to generate date
  • Added the seeding script running, sync and migration database commands to package.json

Steps to test

It will automatically seed when you run docker compose up --build

Steps to test manually*

  1. Ensure the database is running locally and make sure you have initialized the database npx prisma migrate dev --name init
  2. In the root directory, npx @snaplet/seed sync to sync the seed file to any change in the data models of the database
  3. npx prisma db seed to seed the database based on seed.ts
  4. Run docker exec -it sistema-db-1 /bin/bash and then in the container run psql -U sistema -d sistema to enter the Postgres shell
  5. In the Postgres shell check if the database tables are seeded by running SELECT * FROM public."<Table-name>"; eg: SELECT * FROM public."Absence";

What should reviewers focus on?

  • All the tables are seeded correctly with correct data and are in sync with each other

Checklist

  • My PR name is descriptive and in imperative tense
  • My commit messages are descriptive and in imperative tense. My commits are atomic and trivial commits are squashed or fixup'd into non-trivial commits
  • I have run the appropriate linter(s)
  • I have requested a review from the PL, as well as other devs who have background knowledge on this PR or who will be building on top of this PR

@ChinemeremChigbo
Copy link
Member

Please also add instructions for running the seeding script to the README.

@VJagiasi
Copy link
Collaborator Author

VJagiasi commented Jul 3, 2024

Please also add instructions for running the seeding script to the README.

Added

Copy link
Member

@ChinemeremChigbo ChinemeremChigbo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix your merge conflicts and make sure your seeding script matches the updated schema.

@ChinemeremChigbo
Copy link
Member

Conditional-Postinstall seems to be required for the seeding script to not interfere with deployment. I tried removing it and reverting to only using start.sh, but the deployments failed after that occurred, which is likely due to Prisma needing different Postinstall scripts to work locally and in deployment. Error messages could not be viewed due to a lack of Vercel pro accounts.

Fixed the failing builds. We need to sync @ludavidca @anantduggal @RahulTandon1 to fix the lack of build introspection.

Dockerfile Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
docker-compose.yml Outdated Show resolved Hide resolved
prisma/migrations/20240623012346_init/migration.sql Outdated Show resolved Hide resolved
prisma/migrations/20240712012504_init/migration.sql Outdated Show resolved Hide resolved
Copy link
Collaborator

@ludavidca ludavidca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. All issues are resolved.

Copy link
Member

@ChinemeremChigbo ChinemeremChigbo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LBTM

@ludavidca ludavidca merged commit 00f787e into main Sep 28, 2024
3 checks passed
@ludavidca ludavidca deleted the vihaan/seeding-script branch September 28, 2024 23:32
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.

6 participants