-
Notifications
You must be signed in to change notification settings - Fork 8
refactor: 멘토의 합격 팁, 자기 소개가 null 을 허용하지 않도록 #443
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
refactor: 멘토의 합격 팁, 자기 소개가 null 을 허용하지 않도록 #443
Conversation
Walkthrough
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Suggested reviewers
✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/main/java/com/example/solidconnection/mentor/domain/Mentor.java (1)
35-36: 런타임 검증 강화 제안: @NotBlank/@SiZe 추가 권장
애플리케이션 레벨에서 빈 문자열과 길이 초과를 조기에 방지하면 UX와 오류 메시지를 크게 개선할 수 있습니다.
현재 grep 결과로 null 전달 흔적은 발견되지 않았으나, 호출부 검증이 더 필요합니다.
필드 Bean Validation 추가
• src/main/java/com/example/solidconnection/mentor/domain/Mentor.java
• introduction, passTip 필드에 아래와 같이 어노테이션 적용- @Column(length = 1000, nullable = false) + @NotBlank + @Size(max = 1000) + @Column(length = 1000, nullable = false) private String introduction; - @Column(length = 1000, nullable = false) + @NotBlank + @Size(max = 1000) + @Column(length = 1000, nullable = false) private String passTip;• import 추가
import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.Size;DTO/컨트롤러 단계 검증 활성화
• Request DTO에 @notblank, @SiZe(max = 1000) 부여
• @Valid 및 BindingResult 처리를 통해 조기 차단호출부 null/blank 인자 방지
• updateIntroduction/updatePassTip 호출부에서 null 혹은 공백 문자열이 넘어가지 않도록 검증 로직 추가추가로, 테스트 데이터·마이그레이션 스크립트 내 null 입력이 없는지 수동으로 한 번 더 확인해 주세요.
src/main/resources/db/migration/V28__alter_mentor_introduction_pass_tip_not_null.sql (1)
1-5: 2) 락 영향 최소화 — 두 컬럼을 한 번에 ALTER로 처리
- 동일 테이블에 대한 ALTER를 하나로 합치면 테이블 재작성/락 횟수를 줄일 수 있습니다.
- InnoDB/버전에 따라 ONLINE/INPLACE 여부가 달라지니 배포창에서 점검하세요.
권장 수정:
-ALTER TABLE mentor - MODIFY introduction VARCHAR(1000) NOT NULL; - -ALTER TABLE mentor - MODIFY pass_tip VARCHAR(1000) NOT NULL; +ALTER TABLE mentor + MODIFY introduction VARCHAR(1000) NOT NULL, + MODIFY pass_tip VARCHAR(1000) NOT NULL;추가 팁:
- 대용량 환경이면 오프피크 적용, 트랜잭션 길이 최소화, 백업/롤백 계획 점검을 권장합니다.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/main/java/com/example/solidconnection/mentor/domain/Mentor.java(1 hunks)src/main/resources/db/migration/V28__alter_mentor_introduction_pass_tip_not_null.sql(1 hunks)
🔇 Additional comments (2)
src/main/java/com/example/solidconnection/mentor/domain/Mentor.java (1)
35-36: 1) 엔티티에 NOT NULL 적용 OK — 요구사항과 일치합니다
- 목적(두 컬럼의 NULL 금지)과 정확히 일치합니다.
- 마이그레이션과도 설정이 일관됩니다. 좋습니다.
Also applies to: 38-39
src/main/resources/db/migration/V28__alter_mentor_introduction_pass_tip_not_null.sql (1)
1-5: 문제 없음: MySQL 사용 환경 확인 완료
- 의존성 확인
– build.gradle에com.mysql:mysql-connector-j및org.flywaydb:flyway-mysql의존성 포함- 구문 호환성 검증
– ALTER TABLE … MODIFY 구문이 MySQL에서 정상 작동함이 확인됨해당 마이그레이션 스크립트는 그대로 머지하셔도 좋습니다.
| ALTER TABLE mentor | ||
| MODIFY introduction VARCHAR(1000) NOT NULL; | ||
|
|
||
| ALTER TABLE mentor | ||
| MODIFY pass_tip VARCHAR(1000) NOT NULL; |
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.
1) 기존 데이터에 NULL 존재 시 실패 가능 — 선행 백필 쿼리 추가 필요
- 현재 스크립트는 NOT NULL만 강제합니다.
- 만약 프로덕션/스테이징에 NULL 레코드가 남아 있으면 마이그레이션이 실패합니다.
권장 백필(실행 환경에 맞춘 값으로 조정 권장: 빈 문자열/플레이스홀더/N/A 등):
-- 선행 백필
UPDATE mentor SET introduction = '' WHERE introduction IS NULL;
UPDATE mentor SET pass_tip = '' WHERE pass_tip IS NULL;
-- 이후 스키마 변경
ALTER TABLE mentor
MODIFY introduction VARCHAR(1000) NOT NULL,
MODIFY pass_tip VARCHAR(1000) NOT NULL;검증 쿼리(사전/사후):
SELECT
SUM(CASE WHEN introduction IS NULL THEN 1 ELSE 0 END) AS null_intro,
SUM(CASE WHEN pass_tip IS NULL THEN 1 ELSE 0 END) AS null_pass_tip
FROM mentor;원하시면 백필 포함 2-step 마이그레이션으로 스크립트를 다듬어 드리겠습니다(테이블 잠금/다운타임 고려 포함).
🤖 Prompt for AI Agents
In
src/main/resources/db/migration/V28__alter_mentor_introduction_pass_tip_not_null.sql
around lines 1-5, the migration sets introduction and pass_tip to NOT NULL but
does not handle existing NULL values which will cause the migration to fail; add
a pre-fill step that updates mentor rows to a safe default (e.g., empty string
or chosen placeholder) where these columns are NULL, then run the ALTER TABLE to
modify both columns to NOT NULL in a single statement, and optionally include a
pre/post validation SELECT to count NULLs to ensure the backfill succeeded
before changing the schema.
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.
어차피 지금 멘토 없으니까 이건 무시해도 되겠네요
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.
@Gyuhyeok99, 네 이해했습니다! 현재 멘토 데이터가 없다면 백필 없이 바로 NOT NULL 제약 조건을 추가해도 안전하겠네요. 👍
✏️ Learnings added
Learnt from: Gyuhyeok99
PR: solid-connection/solid-connect-server#443
File: src/main/resources/db/migration/V28__alter_mentor_introduction_pass_tip_not_null.sql:1-5
Timestamp: 2025-08-11T14:39:49.430Z
Learning: The mentor table currently has no data in production/staging environment, so NULL backfill operations are not needed when adding NOT NULL constraints to the introduction and pass_tip columns in the mentor table.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
Gyuhyeok99
left a comment
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.
확인했습니다!
저도 V28로 채팅방 관련 pr에 올려놨는데 아마 영서님 것이 먼저 머지될 거 같아서 머지되면 제 PR에서 V29로 업데이트해놓겠습니다~
whqtker
left a comment
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.
확인했습니다 !
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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/main/resources/db/migration/V29__alter_mentor_introduction_pass_tip_not_null.sql (2)
1-5: 두 번의 ALTER를 하나로 병합하여 테이블 재구성/락을 최소화하세요.
동일 테이블을 두 번 ALTER하면 재구성/락이 2회 발생할 수 있습니다. 한 문장으로 합치면 DDL 비용을 줄일 수 있습니다. (MySQL 기준)
- 가용성. 단일 ALTER로 테이블 락 시간을 줄입니다.
- 성능. 테이블 재구성/통계 갱신 횟수를 줄입니다.
다음과 같이 병합을 제안합니다.
-ALTER TABLE mentor - MODIFY introduction VARCHAR(1000) NOT NULL; - -ALTER TABLE mentor - MODIFY pass_tip VARCHAR(1000) NOT NULL; +ALTER TABLE mentor + MODIFY introduction VARCHAR(1000) NOT NULL, + MODIFY pass_tip VARCHAR(1000) NOT NULL;
1-5: 기존 NULL/길이 초과 데이터로 인한 실패를 사전에 방지하세요.
운영/스테이징에는 데이터가 없다는 러닝이 있지만, 로컬/테스트 DB에는 NULL 또는 1000자 초과 데이터가 있을 수 있습니다.
- 안전망. NOT NULL 전에 NULL을 빈 문자열로 보정하면 마이그레이션 실패를 막을 수 있습니다.
- 품질. 길이 초과 데이터는 사전 점검이 필요합니다.
NULL 보정이 필요한 경우, ALTER 전에 아래 UPDATE를 추가해 주세요.
+UPDATE mentor SET introduction = '' WHERE introduction IS NULL; +UPDATE mentor SET pass_tip = '' WHERE pass_tip IS NULL; + ALTER TABLE mentor MODIFY introduction VARCHAR(1000) NOT NULL; ALTER TABLE mentor MODIFY pass_tip VARCHAR(1000) NOT NULL;길이 초과 데이터 점검 쿼리 예시(참고, 수동 실행):
- MySQL: SELECT id FROM mentor WHERE CHAR_LENGTH(introduction) > 1000 OR CHAR_LENGTH(pass_tip) > 1000;
- PostgreSQL: SELECT id FROM mentor WHERE LENGTH(introduction) > 1000 OR LENGTH(pass_tip) > 1000;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/main/resources/db/migration/V29__alter_mentor_introduction_pass_tip_not_null.sql(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: Gyuhyeok99
PR: solid-connection/solid-connect-server#443
File: src/main/resources/db/migration/V28__alter_mentor_introduction_pass_tip_not_null.sql:1-5
Timestamp: 2025-08-11T14:39:49.430Z
Learning: The mentor table currently has no data in production/staging environment, so NULL backfill operations are not needed when adding NOT NULL constraints to the introduction and pass_tip columns in the mentor table.
📚 Learning: 2025-08-11T14:39:49.430Z
Learnt from: Gyuhyeok99
PR: solid-connection/solid-connect-server#443
File: src/main/resources/db/migration/V28__alter_mentor_introduction_pass_tip_not_null.sql:1-5
Timestamp: 2025-08-11T14:39:49.430Z
Learning: The mentor table currently has no data in production/staging environment, so NULL backfill operations are not needed when adding NOT NULL constraints to the introduction and pass_tip columns in the mentor table.
Applied to files:
src/main/resources/db/migration/V29__alter_mentor_introduction_pass_tip_not_null.sql
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
🔇 Additional comments (3)
src/main/resources/db/migration/V29__alter_mentor_introduction_pass_tip_not_null.sql (3)
1-5: 의도 정렬 및 제약 강화 LGTM.
이 PR 목적(mentor.introduction/pass_tip를 NOT NULL로 전환)에 정확히 부합합니다.
- 제약 강화. 두 컬럼 모두 NOT NULL이 되어 데이터 일관성이 좋아집니다.
- 길이 유지. VARCHAR(1000) 스펙이 유지되어 JPA 설정과 일치합니다.
- 도메인 합의 반영. 지난 회의 결정을 스키마에 정확히 반영했습니다.
1-5: DB 벤더 확인이 필요합니다!application.yml에서
spring.datasource.url또는flyway.url설정이 발견되지 않았습니다.
따라서 현재 사용 중인 DB 벤더(MySQL/MariaDB vs PostgreSQL)를 명확히 확인해야 합니다.변경 사항 안내:
- DB 벤더 확인
- 환경 변수, CI/CD 설정 또는 배포 문서를 참고하여 실제 사용 중인 DB 벤더를 파악하세요.
- MySQL/MariaDB 사용 시
- 기존 스크립트(
MODIFY)를 그대로 적용하시면 됩니다.- PostgreSQL 사용 시
- 아래처럼
ALTER COLUMN구문으로 대체해주세요.-ALTER TABLE mentor - MODIFY introduction VARCHAR(1000) NOT NULL; - -ALTER TABLE mentor - MODIFY pass_tip VARCHAR(1000) NOT NULL; +ALTER TABLE mentor + ALTER COLUMN introduction TYPE VARCHAR(1000), + ALTER COLUMN introduction SET NOT NULL, + ALTER COLUMN pass_tip TYPE VARCHAR(1000), + ALTER COLUMN pass_tip SET NOT NULL;위 안내에 따라 DB 스크립트를 조정해 주세요.
1-5: 중복 마이그레이션 없음 확인
변경 내역을 살펴본 결과, introduction∙pass_tip NOT NULL 제약 추가는 오직 V29에만 포함되어 있습니다.
- V19__create_mentor_related_tables.sql
- introduction, pass_tip 컬럼 생성 시 NULL 허용 상태로 생성됨.
- V26__add_term_column_to_mentor.sql
- term 컬럼만 추가됨.
- V29__alter_mentor_introduction_pass_tip_not_null.sql
- introduction, pass_tip 컬럼을 NOT NULL으로 변경함.
따라서 동일한 DDL이 중복 적용된 마이그레이션은 없으며, V29이 유일한 변경점입니다. 안심하고 머지하세요!
관련 이슈
작업 내용
지난 회의에서 결정된 내용을 적용합니다.
nullable = false를 추가했습니다.