Skip to content

Conversation

@whqtker
Copy link
Member

@whqtker whqtker commented Oct 12, 2025

관련 이슈

  • resolves: #이슈 번호

작업 내용

상황

  • application 테이블만 createAt, updateAt이 생성됨, 다른 테이블은 gpa 테이블 때문에 실행 X
  • metoring 테이블은 이미 createAt 존재함

작업

  1. history에서 V34 관련 레코드 제거
  2. application 테이블의 createAt, updateAt drop
  3. V34 파일의 gpa, language_test 제거, mentoring의 createAt 추가 제거

특이 사항

리뷰 요구사항 (선택)

@whqtker whqtker self-assigned this Oct 12, 2025
@whqtker whqtker added the 버그 Something isn't working label Oct 12, 2025
@coderabbitai
Copy link

coderabbitai bot commented Oct 12, 2025

Walkthrough

  1. Mentoring 엔티티 변경.
    클래스에서 createdAt 필드와 @PrePersist 메서드(onPrePersist)가 제거되어 생성 시각 저장 및 자동 초기화 로직이 삭제되었습니다.
    나머지 필드(confirmedAt, checkedAtByMentor, checkedAtByMentee, verifyStatus, mentorId, menteeId)와 동작(confirm, checkByMentor, checkByMentee)은 유지됩니다.
  2. DB 마이그레이션 스크립트 변경.
    V34 마이그레이션에서 gpa, language_test, mentoring 테이블에 대한 created_at 컬럼 추가가 제거되어 해당 테이블에는 이제 updated_at만 추가됩니다.
  3. 테스트 픽스처 변경.
    MentoringFixtureBuilder에서 createdAt 설정 메서드와 해당 인자를 사용하는 생성자 호출이 제거되어 빌더 인수 목록 및 호출 순서가 조정되었습니다.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • wibaek
  • Hexeong
  • Gyuhyeok99
  • lsy1307
  • JAEHEE25

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description Check ⚠️ Warning 설명에는 관련 이슈와 작업 내용 구조가 마련되어 있으나 이슈 번호가 placeholder로 남아 있고 작업 내용 섹션의 템플릿 주석이 제거되지 않아 구체적 변경 사항이 불분명합니다. 관련 이슈에 실제 이슈 번호를 기재하고 작업 내용 섹션에서 주석을 제거한 뒤 각 변경 사항과 특이 사항을 간략히 채워 주세요.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed PR 제목은 “BaseEntity 관련 마이그레이션 파일 수정”이라는 주요 변경사항을 명확하고 간결하게 요약하며 실제 변경 내용과 잘 부합합니다.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eaa8eb4 and 5e5ce5d.

📒 Files selected for processing (1)
  • src/test/java/com/example/solidconnection/mentor/fixture/MentoringFixtureBuilder.java (0 hunks)
💤 Files with no reviewable changes (1)
  • src/test/java/com/example/solidconnection/mentor/fixture/MentoringFixtureBuilder.java
⏰ 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

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

Comment @coderabbitai help to get the list of available commands and usage tips.

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 (1)
src/main/resources/db/migration/V34__add_baseentity_related_fields.sql (1)

1-194: 중복되는 컬럼 추가 로직을 공통화해 주세요.

  1. 중복 제거 제안
    • 현재 테이블마다 SET @col_existsPREPAREEXECUTEDEALLOCATE 패턴을 반복하면서 스크립트가 길고 유지보수 비용이 높아졌습니다.
    • 테이블명과 컬럼명을 매개변수로 받아 처리하는 임시 프로시저(예: CALL add_baseentity_columns('application'))를 정의·호출하면 가독성도 좋아지고, 추후 컬럼 정의가 바뀌어도 한 곳만 수정하면 됩니다.
    • Flyway에서는 CREATE PROCEDURE ... 후 즉시 CALL하고 마지막에 DROP PROCEDURE 하는 패턴을 지원하므로 구현 부담이 크지 않습니다.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e285803 and c234aaf.

📒 Files selected for processing (2)
  • src/main/java/com/example/solidconnection/mentor/domain/Mentoring.java (0 hunks)
  • src/main/resources/db/migration/V34__add_baseentity_related_fields.sql (1 hunks)
💤 Files with no reviewable changes (1)
  • src/main/java/com/example/solidconnection/mentor/domain/Mentoring.java

@whqtker whqtker force-pushed the fix/baseentity-prob branch from c234aaf to eaa8eb4 Compare October 12, 2025 15:25
Copy link
Contributor

@Hexeong Hexeong 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
Contributor

@sukangpunch sukangpunch 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
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.

이거 이미 머지된 스크립트 파일 수정해도 되나요?

Comment on lines -5 to -12
ALTER TABLE gpa
ADD COLUMN created_at DATETIME(6),
ADD COLUMN updated_at DATETIME(6);

ALTER TABLE language_test
ADD COLUMN created_at DATETIME(6),
ADD COLUMN updated_at DATETIME(6);

Copy link
Contributor

Choose a reason for hiding this comment

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

@coderabbitai
이미 개발서버에 반영된 flaway 스크립트 파일 수정해도 문제 없는지 알려줘

Copy link

Choose a reason for hiding this comment

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

@Gyuhyeok99

Flyway 마이그레이션 파일 수정 관련 답변

이미 개발 서버에 반영된 Flyway 스크립트를 수정하는 것은 일반적으로 권장되지 않습니다. 다음 이유들 때문입니다:

1. 체크섬 검증 실패 위험

Flyway는 각 마이그레이션 파일의 체크섬을 flyway_schema_history 테이블에 저장합니다. 이미 실행된 파일을 수정하면 체크섬이 달라져서 다음 배포 시 Flyway가 검증 오류를 발생시킵니다:

Validate failed: Migration checksum mismatch

2. 환경 간 불일치 문제

  • 다른 개발자의 로컬 환경
  • 스테이징 환경
  • 프로덕션 환경

위 환경들과 동기화 문제가 발생할 수 있습니다.

3. 현재 PR의 접근 방식 분석

PR에서 수행하는 작업:

  1. flyway_schema_history에서 V34 레코드 삭제
  2. application 테이블에서 컬럼 수동 삭제
  3. ✅ V34 파일 수정

이 방식은 개발 환경에서는 가능하지만 몇 가지 주의사항이 있습니다:

4. 권장 사항

옵션 A: 새로운 마이그레이션 생성 (권장)

-- V35__fix_baseentity_fields.sql
-- application 테이블 롤백
ALTER TABLE application DROP COLUMN created_at;
ALTER TABLE application DROP COLUMN updated_at;

-- 올바른 테이블에 적용
ALTER TABLE application ADD COLUMN created_at DATETIME(6);
ALTER TABLE application ADD COLUMN updated_at DATETIME(6);
-- ... 다른 테이블들

옵션 B: 기존 파일 수정 (현재 PR 방식)

만약 V34를 수정해야 한다면:

필수 체크리스트:

  • 모든 개발자의 로컬 DB를 리셋하거나 동일한 수동 작업 수행
  • V34가 실행된 모든 환경(개발서버 등)에서 수동으로 rollback + history 삭제
  • V34가 프로덕션에 반영되지 않았는지 확인
  • 팀 전체에 공지

실행 순서:

-- 1. 각 환경에서 실행
DELETE FROM flyway_schema_history WHERE version = '34';
ALTER TABLE application DROP COLUMN IF EXISTS created_at;
ALTER TABLE application DROP COLUMN IF EXISTS updated_at;

-- 2. 그 후 수정된 V34 파일로 Flyway 재실행

5. 주의사항

  • ⚠️ 프로덕션에 이미 반영되었다면 절대 수정하지 마세요
  • ⚠️ 팀원들과 반드시 공유하고 조율하세요
  • ⚠️ 이 작업은 데이터 손실 위험이 있으니 백업을 권장합니다

결론

개발 서버에만 반영되었고 프로덕션에는 반영되지 않았다면, PR의 접근 방식도 가능합니다. 하지만 새로운 마이그레이션 파일(V35)을 생성하는 것이 더 안전하고 Flyway의 의도된 사용 방식입니다.

어떤 방식을 선택하시겠습니까?

Copy link
Contributor

Choose a reason for hiding this comment

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

@whqtker 이거 확인 한 번 부탁드립니다

Copy link

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Copy link
Member Author

Choose a reason for hiding this comment

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

@coderabbitai 애초에 V34 스크립트가 잘못되었기에(gpa 테이블은 존재하지 않음) V35 스크립트를 작성한다 한들, V34 적용 시 문제가 발생하고, V35는 적용되지 않는 거 아니니 ?

Copy link

Choose a reason for hiding this comment

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

@whqtker 정확한 지적입니다! 말씀하신 대로 V34가 실행 중 실패했기 때문에 V35로 해결할 수 없는 상황입니다.

상황 분석

문제점

  1. V34 스크립트가 존재하지 않는 gpa 테이블에 대한 ALTER TABLE 구문을 포함
  2. Flyway가 V34 실행 중 gpa 테이블에서 에러 발생
  3. V34가 실패 상태로 flyway_schema_history에 기록됨 (또는 부분적으로만 실행됨)
  4. 이후 마이그레이션(V35, V36 등)은 실행되지 않음

V35 생성이 작동하지 않는 이유

V34 실행 → gpa 테이블 없음 → 실패 → STOP
                                    ↓
                              V35는 실행되지 않음

현재 PR의 접근 방식이 올바른 이유

말씀하신 것처럼 V34 자체를 수정하는 것이 유일한 해결책입니다:

수정된 V34의 내용

-- ❌ 제거: 존재하지 않는 테이블
-- ALTER TABLE gpa ...
-- ALTER TABLE language_test ...

-- ✅ 유지: 실제 존재하는 테이블들
ALTER TABLE application
    ADD COLUMN created_at DATETIME(6),
    ADD COLUMN updated_at DATETIME(6);

-- ✅ updated_at만 추가 (created_at는 이미 존재)
ALTER TABLE mentoring
    ADD COLUMN updated_at DATETIME(6);

-- ... 나머지 테이블들

필요한 작업 (PR에서 수행 중)

  1. flyway_schema_history에서 V34 레코드 삭제
  2. application 테이블의 created_at, updated_at 수동 삭제
  3. ✅ V34 파일 수정 (gpa, language_test 제거)
  4. ✅ Flyway 재실행

결론

이전 답변에서 V35 생성을 권장했지만, V34가 실패한 상황에서는 V34 자체를 수정하는 것이 올바른 접근입니다. 제 답변이 현재 상황을 충분히 고려하지 못했습니다.

현재 PR의 접근 방식이 정확하며, 다음을 확인하시면 됩니다:

  • 개발 서버에서 V34 관련 히스토리 삭제
  • application 테이블 컬럼 수동 삭제
  • 수정된 V34로 재실행
  • 팀원들에게 동일한 작업 공유

Copy link
Member Author

@whqtker whqtker Oct 14, 2025

Choose a reason for hiding this comment

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

@coderabbitai 답변, PR 등을 고려하지 않고 오로지 현 문제에 초점을 맞췄을 때, 가장 현명한 해결 방법은 무엇인가 ?

Copy link

Choose a reason for hiding this comment

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

@whqtker

가장 현명한 해결 방법

오로지 기술적 관점에서 볼 때, 가장 깔끔한 해결 방법은 다음과 같습니다:

해결 전략: V34 수정 + Flyway Repair

1️⃣ 현재 상태 파악

-- flyway_schema_history 확인
SELECT version, description, type, script, checksum, installed_on, execution_time, success
FROM flyway_schema_history 
WHERE version = '34';

-- application 테이블 구조 확인
DESCRIBE application;

-- mentoring 테이블 구조 확인  
DESCRIBE mentoring;

2️⃣ Flyway 상태 복구

# 옵션 A: Flyway repair 사용 (권장)
flyway repair

# 또는 옵션 B: 수동으로 히스토리 삭제
# DELETE FROM flyway_schema_history WHERE version = '34';

Flyway repair가 하는 일:

  • 실패한 마이그레이션 레코드 제거
  • 체크섬 불일치 해결
  • 누락된 마이그레이션 마커 제거

3️⃣ 부분 적용된 변경사항 롤백

-- application 테이블에만 추가된 컬럼 제거
ALTER TABLE application DROP COLUMN IF EXISTS created_at;
ALTER TABLE application DROP COLUMN IF EXISTS updated_at;

4️⃣ V34 스크립트 수정

-- V34__add_baseentity_related_fields.sql
-- ❌ 제거: 존재하지 않는 테이블
-- ALTER TABLE gpa ...
-- ALTER TABLE language_test ...

ALTER TABLE application
    ADD COLUMN created_at DATETIME(6),
    ADD COLUMN updated_at DATETIME(6);

-- mentoring은 created_at가 이미 존재하므로 updated_at만 추가
ALTER TABLE mentoring
    ADD COLUMN updated_at DATETIME(6);

-- ... 나머지 테이블들

5️⃣ 마이그레이션 재실행

flyway migrate

6️⃣ 검증

-- 모든 테이블에 컬럼이 올바르게 추가되었는지 확인
SELECT 
    TABLE_NAME,
    COLUMN_NAME,
    DATA_TYPE
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME IN ('created_at', 'updated_at')
    AND TABLE_SCHEMA = DATABASE()
ORDER BY TABLE_NAME, COLUMN_NAME;

왜 이 방법이 가장 현명한가?

장점

  1. 마이그레이션 히스토리가 깔끔함 - V34가 실제 의도대로 기록됨
  2. 재현 가능성 - 새로운 환경(로컬, CI/CD)에서 동일하게 작동
  3. Flyway 원칙 준수 - repair 명령어는 이런 상황을 위해 존재함
  4. 향후 문제 방지 - V35, V36 등이 정상적으로 실행됨

⚠️ 주의사항

  • 프로덕션에 이미 배포되었다면 이 방법을 사용하면 안 됨 (데이터 보존 우선)
  • 개발/스테이징 환경에서만 적용 가능

대안: 새로운 버전으로 보상 (프로덕션이 포함된 경우)

만약 프로덕션에도 V34가 부분적으로 적용되었다면:

-- V35__rollback_v34_and_fix.sql
-- 롤백
ALTER TABLE application DROP COLUMN IF EXISTS created_at;
ALTER TABLE application DROP COLUMN IF EXISTS updated_at;

-- V36__add_baseentity_fields_fixed.sql
-- 올바른 적용
ALTER TABLE application ADD COLUMN created_at DATETIME(6);
-- ... 나머지

하지만 현재는 개발 서버만 영향받았으므로 V34 수정이 최선입니다.

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.

고생하셨습니다~

@whqtker whqtker merged commit 9d639ec into solid-connection:develop Oct 14, 2025
2 checks passed
Gyuhyeok99 added a commit that referenced this pull request Nov 4, 2025
fix: PostRepository & CommentRepository의 일부 메서드의 정렬 순서 오류 해결 (#522) 
refactor: 이메일 유니크키 제거
refactor: 엔티티가 BaseEntity를 상속하도록 (#524) 
fix: BaseEntity 관련 마이그레이션 파일 수정 (#530) 
feat: 멘토 승격 api 구현 (#532) 
fix: 대학교 중복 오류 수정 (#510) 
refactor: 불필요한 로그 삭제 (#543)
fix: 운영환경 8081 포트 설정 추가 (#542) 
fix: dev환경 디비명 변경 (#546)
refactor: 불필요한 로그 삭제 (#547) 
refactor: 학기를 테이블로 관리하도록 변경 (#526) 
refactor: 모의지원 시 지원한 대학 정보 응답 추가 (#539)
@Gyuhyeok99 Gyuhyeok99 mentioned this pull request Nov 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

버그 Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants