Skip to content

chore(be): set profileImageUrl seed into username for recent users & add not null constraint#3597

Open
zero1177 wants to merge 3 commits into
feat/remove-whitelistfrom
chore/profileImage-schema
Open

chore(be): set profileImageUrl seed into username for recent users & add not null constraint#3597
zero1177 wants to merge 3 commits into
feat/remove-whitelistfrom
chore/profileImage-schema

Conversation

@zero1177
Copy link
Copy Markdown
Contributor

Description

  1. migration.sql 수정
  • 기존 user들의 profileImageUrl 필드의 seed 값을 username으로 채워넣는 SQL 작성
    https://api.dicebear.com/9.x/notionists/svg?seed={username}
  • 이후 profileImageUrl 필드를 not null로 제약조건을 추가하는 SQL 작성
  1. seed.ts
    profileImageUrl 시드값을 채워넣는 일부 값을 실제 dicebear Url에 맞춰 수정

Copilot AI review requested due to automatic review settings May 28, 2026 07:49
@zero1177 zero1177 self-assigned this May 28, 2026
@zero1177 zero1177 requested review from juheon429 and nhjbest22 May 28, 2026 07:49
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

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 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.profileImageUrl in Prisma schema from nullable to required.
  • Add a migration to populate profile_image_url and 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.

Comment on lines +8 to +12
-- 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"
);
Comment on lines 119 to 124
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")
@nhjbest22 nhjbest22 mentioned this pull request Jun 2, 2026
4 tasks
Copy link
Copy Markdown
Contributor

@RyuRaseul RyuRaseul left a comment

Choose a reason for hiding this comment

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

Typecheck 확인좀
NOT Null 추가하면서 Type 문제 생긴듯
nickname도 뭐 있네

@nhjbest22
Copy link
Copy Markdown
Contributor

nhjbest22 commented Jun 4, 2026

@zero1177 이거 일단 Merge 하고
#3598 해당 PR에서 새롭게 rebase해서
현재 발생하는 에러들(Type관련 문제 - 아마도 Test Code 쪽 문제일거 같기는 한데) 해결하는 건 어때요?

@nhjbest22
Copy link
Copy Markdown
Contributor

nhjbest22 commented Jun 5, 2026

별도 첨언이긴 한데, ImageUrl에 @default('')를 추가하는 건 어떨까요?
제가 알기로 비어있는 string의 경우에는 Falthy한 값으로 처리가 되니깐 FE에서 예외 처리하기에도 크게 어렵지 않을 거 같아요

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.

4 participants