Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ public class Mentor {
@Column
private boolean hasBadge = false;

@Column(length = 1000)
@Column(length = 1000, nullable = false)
private String introduction;

@Column(length = 1000)
@Column(length = 1000, nullable = false)
private String passTip;

@Column
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ALTER TABLE mentor
MODIFY introduction VARCHAR(1000) NOT NULL;

ALTER TABLE mentor
MODIFY pass_tip VARCHAR(1000) NOT NULL;
Comment on lines +1 to +
Copy link
Copy Markdown

@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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown

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.

Loading