Skip to content

Conversation

@nayonsoso
Copy link
Collaborator

@nayonsoso nayonsoso commented Aug 11, 2025

관련 이슈

작업 내용

image

지난 회의에서 결정된 내용을 적용합니다.

  1. flyway 스크립트로 alter 문을 추가했습니다.
  2. JPA Mentor 엔티티의 introduction, passTip 에 nullable = false를 추가했습니다.

@coderabbitai
Copy link

coderabbitai bot commented Aug 11, 2025

Walkthrough

    1. 도메인 엔티티 제약 강화
    • Mentor.java에서 introduction, passTip 필드에 nullable = false 속성을 추가했습니다.
    • 두 컬럼의 @column(length = 1000) 설정은 유지되며, null 비허용으로 변경되었습니다.
    1. DB 마이그레이션 추가
    • V29 마이그레이션에서 mentor 테이블의 introduction, pass_tip 컬럼을 VARCHAR(1000) NOT NULL로 수정했습니다.
    • 각 컬럼은 별도의 ALTER TABLE ... MODIFY 문으로 적용되었습니다.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested reviewers

  • wibaek
  • lsy1307
  • Gyuhyeok99
  • whqtker
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a 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 전달 흔적은 발견되지 않았으나, 호출부 검증이 더 필요합니다.

  1. 필드 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;
  2. DTO/컨트롤러 단계 검증 활성화
    • Request DTO에 @notblank, @SiZe(max = 1000) 부여
    @Valid 및 BindingResult 처리를 통해 조기 차단

  3. 호출부 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

📥 Commits

Reviewing files that changed from the base of the PR and between 51d1d06 and 4916af4.

📒 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 사용 환경 확인 완료

  1. 의존성 확인
    – build.gradle에 com.mysql:mysql-connector-jorg.flywaydb:flyway-mysql 의존성 포함
  2. 구문 호환성 검증
    – ALTER TABLE … MODIFY 구문이 MySQL에서 정상 작동함이 확인됨

해당 마이그레이션 스크립트는 그대로 머지하셔도 좋습니다.

Comment on lines 1 to 5
ALTER TABLE mentor
MODIFY introduction VARCHAR(1000) NOT NULL;

ALTER TABLE mentor
MODIFY pass_tip VARCHAR(1000) NOT NULL;
Copy link

@coderabbitai coderabbitai bot Aug 11, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

어차피 지금 멘토 없으니까 이건 무시해도 되겠네요

Copy link

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.

Copy link
Contributor

@Gyuhyeok99 Gyuhyeok99 left a 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로 업데이트해놓겠습니다~

Copy link
Member

@whqtker whqtker left a comment

Choose a reason for hiding this comment

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

확인했습니다 !

Copy link

@coderabbitai coderabbitai bot left a 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 기준)

    1. 가용성. 단일 ALTER로 테이블 락 시간을 줄입니다.
    1. 성능. 테이블 재구성/통계 갱신 횟수를 줄입니다.

다음과 같이 병합을 제안합니다.

-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자 초과 데이터가 있을 수 있습니다.

    1. 안전망. NOT NULL 전에 NULL을 빈 문자열로 보정하면 마이그레이션 실패를 막을 수 있습니다.
    1. 품질. 길이 초과 데이터는 사전 점검이 필요합니다.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4916af4 and 5f7d2b4.

📒 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로 전환)에 정확히 부합합니다.

    1. 제약 강화. 두 컬럼 모두 NOT NULL이 되어 데이터 일관성이 좋아집니다.
    1. 길이 유지. VARCHAR(1000) 스펙이 유지되어 JPA 설정과 일치합니다.
    1. 도메인 합의 반영. 지난 회의 결정을 스키마에 정확히 반영했습니다.

1-5: DB 벤더 확인이 필요합니다!

application.yml에서 spring.datasource.url 또는 flyway.url 설정이 발견되지 않았습니다.
따라서 현재 사용 중인 DB 벤더(MySQL/MariaDB vs PostgreSQL)를 명확히 확인해야 합니다.

변경 사항 안내:

  1. DB 벤더 확인
    • 환경 변수, CI/CD 설정 또는 배포 문서를 참고하여 실제 사용 중인 DB 벤더를 파악하세요.
  2. MySQL/MariaDB 사용 시
    • 기존 스크립트(MODIFY)를 그대로 적용하시면 됩니다.
  3. 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에만 포함되어 있습니다.

  1. V19__create_mentor_related_tables.sql
    • introduction, pass_tip 컬럼 생성 시 NULL 허용 상태로 생성됨.
  2. V26__add_term_column_to_mentor.sql
    • term 컬럼만 추가됨.
  3. V29__alter_mentor_introduction_pass_tip_not_null.sql
    • introduction, pass_tip 컬럼을 NOT NULL으로 변경함.

따라서 동일한 DDL이 중복 적용된 마이그레이션은 없으며, V29이 유일한 변경점입니다. 안심하고 머지하세요!

@nayonsoso nayonsoso merged commit 1203d00 into solid-connection:develop Aug 12, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: 멘토의 자기소개, 합격 팁은 필수로 입력하도록

3 participants