Skip to content

[FEATURE] Flyway 설정 추가#121

Merged
fervovita merged 6 commits into
devfrom
feat/#118-flyway
Jul 13, 2026
Merged

[FEATURE] Flyway 설정 추가#121
fervovita merged 6 commits into
devfrom
feat/#118-flyway

Conversation

@fervovita

@fervovita fervovita commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

🚀 Related issue

Closes #118

#️⃣ Summary

  • Flyway를 도입해 DB 스키마를 마이그레이션 파일(V1__init.sql)로 버전 관리합니다.

🔧 Changes

  • V1 초기 스키마 작성 (db/migration/V1__init.sql)
  • 제약 네이밍 규칙 통일
  • ddl-auto: update -> validate 전환
  • 테스트 DB를 H2 -> Testcontainers(MySQL)로 교체

📸 Test Evidence

  • swagger나 postman 결과를 캡쳐하여 첨부

💬 Reviewer Notes

  • 로컬 DB는 기존 스키마를 비우고 재시작해야 합니다.
  • Flyway에 대한 자세한 컨벤션은 노션의 개발 컨벤션/코딩 스타일 참고 부탁드립니다!
  • 마이그레이션이 MYSQL 문법 기반으로 테스트를 위해 H2 스키마를 따로 작성하기 보다는 Testcontainers를 이용해 테스트 하도록 변경했습니다.

Summary by CodeRabbit

  • 새 기능
    • Flyway 기반 데이터베이스 마이그레이션을 활성화하고 초기 스키마 생성을 포함했습니다.
  • 개선
    • 로컬/운영 환경에서 스키마 자동 변경 대신 검증 모드로 동작합니다.
    • 데이터베이스 제약 조건(유니크 제약) 명칭과 사용자 역할 컬럼 길이를 표준화했습니다.
  • 테스트
    • 통합 테스트를 MySQL Testcontainers 기반으로 일관되게 실행하도록 개선했고, 테스트용 배치 조회 설정도 추가했습니다.

@fervovita
fervovita requested a review from Jong0128 as a code owner July 11, 2026 17:21
@fervovita fervovita self-assigned this Jul 11, 2026
@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@fervovita, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 52 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro Plus

Run ID: 94671e8a-7900-4e82-8b76-f3bf67b8a471

📥 Commits

Reviewing files that changed from the base of the PR and between 3c2ae17 and f96fb08.

📒 Files selected for processing (1)
  • src/main/resources/db/migration/V1__init.sql
📝 Walkthrough

Walkthrough

Flyway 의존성과 초기 MySQL 스키마 마이그레이션을 추가하고, 환경별 Hibernate 스키마 처리를 validate로 변경했습니다. 엔티티 제약 이름과 컬럼 매핑을 정리했으며, MySQL Testcontainers 기반 통합 테스트 설정을 도입했습니다.

Changes

Flyway 스키마 및 테스트 전환

Layer / File(s) Summary
Flyway 설정과 초기 마이그레이션
build.gradle, src/main/resources/application.yaml, src/main/resources/db/migration/V1__init.sql
Flyway 의존성과 설정을 추가하고 전체 초기 데이터베이스 스키마를 V1 마이그레이션으로 정의했습니다.
엔티티 스키마 제약 및 컬럼 매핑 정렬
src/main/java/ditda/backend/domain/**/entity/*.java
유니크 제약 이름을 변경하고 User.role 컬럼 길이를 20으로 지정했습니다.
MySQL Testcontainers 통합 테스트 구성
build.gradle, src/test/java/ditda/backend/support/*, src/test/java/ditda/backend/BackendApplicationTests.java, src/test/resources/application-test.yaml
H2 테스트 의존성을 제거하고 MySQL Testcontainers, 공통 통합 테스트 지원 클래스, mysql:8.4 컨테이너 설정을 추가했습니다.
환경별 스키마 검증 모드 적용
src/main/resources/application-local.yaml, src/main/resources/application-prod.yaml
로컬·운영 환경의 ddl-autovalidate로 변경했습니다.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SpringBoot
  participant Flyway
  participant MySQL
  participant Hibernate
  SpringBoot->>Flyway: 설정 로드
  Flyway->>MySQL: V1__init.sql 실행
  MySQL-->>Flyway: 초기 스키마 생성
  SpringBoot->>Hibernate: 엔티티 스키마 검증
  Hibernate->>MySQL: 매핑과 스키마 비교
Loading

Possibly related PRs

Suggested reviewers: jong0128

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목이 Flyway 설정 추가라는 핵심 변경을 간결하게 요약합니다.
Linked Issues check ✅ Passed Flyway 설정, 초기 마이그레이션, 스키마 검증 전환으로 #118의 목표를 충족합니다.
Out of Scope Changes check ✅ Passed 보이는 변경은 Flyway 도입과 MySQL 기반 테스트 전환을 위한 보조 수정으로, 명확한 범위 이탈은 없습니다.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/#118-flyway

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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/resources/application.yaml (1)

16-22: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

프로덕션 환경에서 out-of-order: true 설정을 재검토해 주세요.

out-of-order: true는 공용 설정이므로 프로덕션 프로파일에도 적용됩니다. 병렬 브랜치에서 서로 다른 마이그레이션 버전이 생성될 경우, 순서와 무관하게 적용되어 스키마 불일치가 발생할 수 있습니다. 프로덕션에서는 false로 설정하고, 로컬 개발 환경에서만 true를 허용하는 것을 권장합니다.

♻️ 제안: application-prod.yaml에 오버라이드 추가
spring:
  flyway:
    out-of-order: false
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/resources/application.yaml` around lines 16 - 22, Update the Flyway
configuration so production overrides the shared out-of-order setting to false,
while retaining true only for local development profiles. Use the existing
application-prod.yaml configuration and the flyway.out-of-order property; keep
the shared setting unchanged if local environments depend on it.
src/main/resources/db/migration/V1__init.sql (1)

343-358: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

notification_outboxes 테이블에 outbox 폴링용 복합 인덱스가 누락되었습니다.

Outbox 패턴에서는 일반적으로 SELECT ... WHERE status = 'PENDING' AND scheduled_at <= NOW() ORDER BY scheduled_at LIMIT N 쿼리로 미발송 알림을 폴링합니다. (status, scheduled_at) 복합 인덱스가 없으면 풀 테이블 스캔이 발생하여 데이터가 쌓일수록 성능이 저하됩니다.

♻️ 제안: 복합 인덱스 추가
     PRIMARY KEY (notification_outbox_id)
+    ,
+    KEY idx_notification_outboxes_status_scheduled_at (status, scheduled_at)
 );
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/resources/db/migration/V1__init.sql` around lines 343 - 358,
notification_outboxes 테이블 정의에 outbox 폴링 쿼리를 지원하는 (status, scheduled_at) 복합 인덱스를
추가하세요. 기존 컬럼과 기본 키 정의는 유지하고, status 조건·scheduled_at 범위 및 정렬에 활용되도록 테이블 생성문에 인덱스를
선언하세요.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@build.gradle`:
- Around line 72-76: Restore the `testImplementation
'org.springframework.boot:spring-boot-starter-test'` dependency in the test
dependency declarations so the existing `src/test/java` tests receive JUnit
Jupiter, AssertJ, and Mockito. Keep the current
`spring-boot-starter-webmvc-test` and other test dependencies unchanged.

---

Nitpick comments:
In `@src/main/resources/application.yaml`:
- Around line 16-22: Update the Flyway configuration so production overrides the
shared out-of-order setting to false, while retaining true only for local
development profiles. Use the existing application-prod.yaml configuration and
the flyway.out-of-order property; keep the shared setting unchanged if local
environments depend on it.

In `@src/main/resources/db/migration/V1__init.sql`:
- Around line 343-358: notification_outboxes 테이블 정의에 outbox 폴링 쿼리를 지원하는 (status,
scheduled_at) 복합 인덱스를 추가하세요. 기존 컬럼과 기본 키 정의는 유지하고, status 조건·scheduled_at 범위 및
정렬에 활용되도록 테이블 생성문에 인덱스를 선언하세요.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro Plus

Run ID: 467cbc7a-9fb7-40a8-935d-930f68513dfa

📥 Commits

Reviewing files that changed from the base of the PR and between 3e8429d and 2c801d1.

📒 Files selected for processing (18)
  • build.gradle
  • src/main/java/ditda/backend/domain/commission/category/textbook/entity/TextbookPage.java
  • src/main/java/ditda/backend/domain/commission/core/entity/CommissionColor.java
  • src/main/java/ditda/backend/domain/commission/core/entity/CommissionConcept.java
  • src/main/java/ditda/backend/domain/commission/draft/entity/CommissionDraft.java
  • src/main/java/ditda/backend/domain/commission/draft/entity/CommissionDraftFile.java
  • src/main/java/ditda/backend/domain/commission/revision/entity/RevisionRequest.java
  • src/main/java/ditda/backend/domain/commission/revision/entity/RevisionResponse.java
  • src/main/java/ditda/backend/domain/settlement/entity/Settlement.java
  • src/main/java/ditda/backend/domain/user/entity/User.java
  • src/main/resources/application-local.yaml
  • src/main/resources/application-prod.yaml
  • src/main/resources/application.yaml
  • src/main/resources/db/migration/V1__init.sql
  • src/test/java/ditda/backend/BackendApplicationTests.java
  • src/test/java/ditda/backend/support/IntegrationTestSupport.java
  • src/test/java/ditda/backend/support/TestcontainersConfiguration.java
  • src/test/resources/application-test.yaml

Comment thread build.gradle
@fervovita
fervovita merged commit d60dedc into dev Jul 13, 2026
2 checks passed
@fervovita
fervovita deleted the feat/#118-flyway branch July 13, 2026 08:50
@fervovita fervovita mentioned this pull request Jul 13, 2026
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.

[FEATURE] Flyway 설정 추가

1 participant