chore(be): set profileImageUrl seed into username for recent users & add not null constraint#3597
chore(be): set profileImageUrl seed into username for recent users & add not null constraint#3597zero1177 wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request makes the profileImageUrl field non-nullable in the Prisma schema, updates the database seed data, and adds a migration script to set a default URL and apply the NOT NULL constraint. A critical issue was identified in the migration script where the UPDATE statement lacks a WHERE clause, which would overwrite existing valid profile image URLs instead of only updating NULL values.
There was a problem hiding this comment.
Pull request overview
This PR backfills user_profile.profile_image_url using a Dicebear URL seeded by username, then enforces a NOT NULL constraint so every UserProfile has a profile image URL going forward.
Changes:
- Update
UserProfile.profileImageUrlin Prisma schema from nullable to required. - Add a migration to populate
profile_image_urland then apply a NOT NULL constraint. - Adjust seed data to use real Dicebear URLs instead of placeholder strings.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| apps/backend/prisma/seed.ts | Updates seeded UserProfile.profileImageUrl values to Dicebear URLs. |
| apps/backend/prisma/schema.prisma | Makes UserProfile.profileImageUrl required (non-nullable). |
| apps/backend/prisma/migrations/20260528070352_add_not_null_constraint_to_profile_image_url_field/migration.sql | Backfills profile_image_url and applies a NOT NULL constraint. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| -- Set default profileImageUrl seed to username for users | ||
| UPDATE "public"."user_profile" | ||
| SET "profile_image_url" = 'https://api.dicebear.com/9.x/notionists/svg?seed=' || ( | ||
| SELECT "username" FROM "public"."user" WHERE "user"."id" = "user_profile"."user_id" | ||
| ); |
| id Int @id @default(autoincrement()) | ||
| user User @relation(fields: [userId], references: [id], onDelete: Cascade) | ||
| userId Int @unique @map("user_id") | ||
| realName String @map("real_name") | ||
| profileImageUrl String? @map("profile_image_url") | ||
| profileImageUrl String @map("profile_image_url") | ||
| createTime DateTime @default(now()) @map("create_time") |
|
별도 첨언이긴 한데, ImageUrl에 @default('')를 추가하는 건 어떨까요? |
Description
https://api.dicebear.com/9.x/notionists/svg?seed={username}profileImageUrl 시드값을 채워넣는 일부 값을 실제 dicebear Url에 맞춰 수정