-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Adicionar seed #8
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
Conversation
Atualizar branch com versão mais atual da main
Fará com que quando um usuário for deletado, seja deletado seus relacionamentos filhos (endereço, carrinho, pedido)
feat: Criar seed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new seed script for populating the database and updates the Prisma schema and corresponding migration files. Key changes include adding a seed file using Faker, refactoring model definitions with enums and field mappings (including onDelete rules), and generating SQL migrations reflecting these schema updates.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| prisma/seed.ts | New seed script creating users and associated records using Faker. |
| prisma/schema.prisma | Schema updates with new enums, field mappings (@Map) and relation onDelete rules. |
| prisma/migrations/20250525201034_add_on_delete_cascade_to_users/migration.sql | Migration applying ON DELETE CASCADE to addresses, carts, and orders. |
| prisma/migrations/20250524195941_update_fields_and_add_enums/migration.sql | Migration that modifies fields and adds enums with ON DELETE RESTRICT rules. |
| package.json | Updates to seed commands and dependency versions. |
Comments suppressed due to low confidence (2)
prisma/schema.prisma:48
- The change from a one-to-many to an optional one-to-one relation in the User model may be intentional, but please confirm that each user should now have at most one address.
Address Address?
prisma/migrations/20250524195941_update_fields_and_add_enums/migration.sql:59
- There is an inconsistency with the ON DELETE behavior; this migration uses RESTRICT while a later migration and the Prisma schema expect CASCADE. Ensure that the intended deletion rule is consistently applied across migrations.
CONSTRAINT "addresses_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
| Array.from({ | ||
| length: faker.number.int({ min: 250, max: 300 }), | ||
| }).map(async () => { | ||
| return await prisma.user.create({ |
Copilot
AI
Jun 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 'return await' in the Promise.all map callback is redundant. Consider returning the promise directly to simplify the code.
| return await prisma.user.create({ | |
| return prisma.user.create({ |
No description provided.