[FEAT] Flyway 기반 DB 스키마 관리 도입#286
Conversation
|
Warning Review limit reached
More reviews will be available in 39 minutes and 16 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
WalkthroughHibernate의 자동 스키마 관리에서 Flyway 기반 버전 제어 마이그레이션으로 전환합니다. 의존성과 설정을 추가하고, 현재 스키마를 초기 마이그레이션으로 정의한 후 제약 및 인덱스를 최적화하는 마이그레이션을 순차적으로 적용합니다. ChangesFlyway 마이그레이션 도입
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/main/resources/db/migration/V1__init_schema.sql (1)
6-10: ⚡ Quick win
uk_category_mall_type_name와 같은 키에 인덱스를 하나 더 만들고 있습니다.Line 6의 UNIQUE 제약이 이미 같은 컬럼 순서의 접근 경로를 제공하므로, Line 9-10 인덱스는 쓰기 비용과 저장 공간만 추가할 가능성이 큽니다. 하나만 남기는 편이 낫습니다.
정리 예시
CREATE TABLE category ( category_id BIGINT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY, category_name VARCHAR(50), mall_type VARCHAR(255), aladin_category_id INTEGER NOT NULL, CONSTRAINT uk_category_mall_type_name UNIQUE (mall_type, category_name) ); - -CREATE INDEX idx_category_malltype_name - ON category (mall_type, category_name);🤖 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_schema.sql` around lines 6 - 10, The migration creates a UNIQUE constraint uk_category_mall_type_name on (mall_type, category_name) and then redundantly creates a separate index idx_category_malltype_name on the same columns; remove the duplicate index creation (the CREATE INDEX idx_category_malltype_name ... ON category (mall_type, category_name); lines) and keep the UNIQUE constraint uk_category_mall_type_name so you avoid extra write/storage cost while preserving the same access path.
🤖 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 `@src/main/resources/application.yml`:
- Around line 25-29: The Flyway config in application.yml enables migrations by
default (flyway.enabled / ${FLYWAY_ENABLED:true}) which can run
PostgreSQL-specific scripts against the H2 test DB; to fix, disable Flyway in
the test profile by setting spring.flyway.enabled=false (or
FLyWAY_ENABLED=false) in application-test.yml, or split the test profile to use
PostgreSQL/Testcontainers so that flyway.locations and baseline settings in
application.yml only run against the intended Postgres environment; update
application-test.yml to explicitly override flyway.enabled accordingly.
In
`@src/main/resources/db/migration/V2__add_unique_index_for_aladin_book_isbn.sql`:
- Around line 1-4: The partial unique index ux_book_aladin_isbn13 in
V2__add_unique_index_for_aladin_book_isbn.sql can fail if duplicate rows already
exist for (source_type='ALADIN' AND isbn13 IS NOT NULL); add a safe
pre-migration that detects and resolves duplicates (e.g., run the provided GROUP
BY SELECT to find duplicates and a cleanup step that keeps one row per isbn13 —
e.g., delete others by id or merge data), then create the unique index using
CREATE UNIQUE INDEX CONCURRENTLY ux_book_aladin_isbn13 ON book(isbn13) WHERE
source_type='ALADIN' AND isbn13 IS NOT NULL in a follow-up migration so Flyway
won’t fail on existing duplicates and the index is built safely.
---
Nitpick comments:
In `@src/main/resources/db/migration/V1__init_schema.sql`:
- Around line 6-10: The migration creates a UNIQUE constraint
uk_category_mall_type_name on (mall_type, category_name) and then redundantly
creates a separate index idx_category_malltype_name on the same columns; remove
the duplicate index creation (the CREATE INDEX idx_category_malltype_name ... ON
category (mall_type, category_name); lines) and keep the UNIQUE constraint
uk_category_mall_type_name so you avoid extra write/storage cost while
preserving the same access path.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1679c029-fc07-46aa-9c4f-4df07c778d81
📒 Files selected for processing (6)
build.gradlesrc/main/java/app/nook/book/init/CategoryInitializer.javasrc/main/resources/application.ymlsrc/main/resources/db/migration/V1__init_schema.sqlsrc/main/resources/db/migration/V2__add_unique_index_for_aladin_book_isbn.sqlsrc/main/resources/db/migration/V3__cleanup_legacy_hibernate_schema.sql
💤 Files with no reviewable changes (1)
- src/main/java/app/nook/book/init/CategoryInitializer.java
|
📄 작업 내용 요약
ddl-auto기본값을validate로 변경📎 Issue 번호
✅ 작업 목록
📝 기타 참고사항
Summary by CodeRabbit
릴리스 노트
데이터베이스 개선
구성 변경