Skip to content

Conversation

@lucaslinyker
Copy link
Collaborator

No description provided.

lucaslinyker and others added 6 commits May 21, 2025 13:37
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)
@lucaslinyker lucaslinyker requested a review from Copilot June 4, 2025 11:19
Copy link

Copilot AI left a 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({
Copy link

Copilot AI Jun 4, 2025

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.

Suggested change
return await prisma.user.create({
return prisma.user.create({

Copilot uses AI. Check for mistakes.
@lucaslinyker lucaslinyker merged commit 8f6c370 into dev Jun 4, 2025
2 checks passed
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.

2 participants