Repository navigation
665 db 버전 관리 툴 적용 - #666
Hidden character warning
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, 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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughFlyway 데이터베이스 마이그레이션 시스템을 도입하여 빌드 의존성, 애플리케이션 설정, 초기 스키마 정의, 그리고 마이그레이션 정리를 수행합니다. 관리자와 사용자 중심의 도메인 모델을 V1 baseline으로 통합하고 버전 관리를 시작합니다. ChangesFlyway 마이그레이션 시스템 도입
Sequence Diagram(s)sequenceDiagram
participant SpringBoot as Spring Boot App
participant Flyway as Flyway Engine
participant Migration as V1__baseline.sql
participant Database as MySQL Database
SpringBoot->>Flyway: 애플리케이션 시작 시 마이그레이션 실행
Flyway->>Database: baseline 테이블 확인
Flyway->>Migration: classpath:db/migration 스캔 및 마이그레이션 파일 로드
Migration->>Database: 테이블 생성 (tbl_admin, tbl_user, tbl_notice 등)
Migration->>Database: 외래키 및 제약조건 설정
Migration->>Database: 인덱스 생성
Database-->>Flyway: 마이그레이션 성공
Flyway-->>SpringBoot: 애플리케이션 시작 계속
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
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)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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: 3
🤖 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 @.gitignore:
- Line 47: 현재 .gitignore에 있는 예외 규칙 "!.idea/fileTemplates"는 디렉터리만 제외하고 하위 파일은 계속
무시될 수 있으니, .gitignore에서 예외를 디렉터리와 그 내부 모든 파일로 확장하도록 "!.idea/fileTemplates/"와
"!.idea/fileTemplates/**" 같은 패턴을 추가해 하위 템플릿 파일들이 실제로 unignore 되게 수정하세요 (기존에
".idea/" 전체를 무시하는 규칙이 있으면 해당 규칙 이후에 이 예외들을 배치하세요).
In `@src/main/resources/application.yaml`:
- Around line 55-56: The Flyway setting baseline-on-migrate is hardcoded true
which weakens safety; change baseline-on-migrate to false (or remove the key to
use default false) in application.yaml and only enable it explicitly per
environment where needed, and keep baseline-version as-is if used; ensure any
environment-specific activation is done via profile-specific YAML or environment
variables rather than the global application.yaml.
In `@src/main/resources/db/migration/V202605142000__Drop_User.sql`:
- Line 1: The migration DROP TABLE `user` must be made idempotent to avoid
failures when the table is already absent; update the migration
(V202605142000__Drop_User.sql) to use DROP TABLE IF EXISTS `user` so the
statement succeeds harmlessly if the table doesn't exist.
🪄 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.yaml
Review profile: CHILL
Plan: Pro
Run ID: 606acfdb-62de-4fb6-90e7-df20a6ca1633
📒 Files selected for processing (13)
.gitignore.idea/fileTemplates/Flyway Migration Templates.sqlbuild.gradle.ktsbuildSrc/src/main/kotlin/Dependencies.ktsrc/main/resources/application.yamlsrc/main/resources/db/migration/V1__baseline.sqlsrc/main/resources/db/migration/V202605142000__Drop_User.sqlsrc/main/resources/db/migration/V2_add_move_column_to_classroom.sqlsrc/main/resources/db/migration/V2_entity_mapping_admin.sqlsrc/main/resources/db/migration/V2_entity_mapping_user.sqlsrc/main/resources/db/migration/V3_add_unique_constraint_to_weekend_meal_period_admin_id.sqlsrc/main/resources/db/migration/V3_create_device_token_tables.sqlsrc/main/resources/db/migration/V4_add_unique_constraint_to_meal_date_and_type.sql
💤 Files with no reviewable changes (6)
- src/main/resources/db/migration/V3_add_unique_constraint_to_weekend_meal_period_admin_id.sql
- src/main/resources/db/migration/V2_entity_mapping_admin.sql
- src/main/resources/db/migration/V2_add_move_column_to_classroom.sql
- src/main/resources/db/migration/V4_add_unique_constraint_to_meal_date_and_type.sql
- src/main/resources/db/migration/V2_entity_mapping_user.sql
- src/main/resources/db/migration/V3_create_device_token_tables.sql
| .env | ||
|
|
||
| ### File Template ### | ||
| !.idea/fileTemplates |
There was a problem hiding this comment.
.idea/fileTemplates 예외 규칙이 하위 파일까지 해제되지 않습니다.
현재 패턴은 디렉터리 경로만 예외 처리해서, 실제 템플릿 파일(.idea/fileTemplates/**)은 계속 ignore 될 수 있습니다.
🔧 제안 수정
-!.idea/fileTemplates
+!.idea/fileTemplates/
+!.idea/fileTemplates/**📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| !.idea/fileTemplates | |
| !.idea/fileTemplates/ | |
| !.idea/fileTemplates/** |
🤖 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 @.gitignore at line 47, 현재 .gitignore에 있는 예외 규칙 "!.idea/fileTemplates"는 디렉터리만
제외하고 하위 파일은 계속 무시될 수 있으니, .gitignore에서 예외를 디렉터리와 그 내부 모든 파일로 확장하도록
"!.idea/fileTemplates/"와 "!.idea/fileTemplates/**" 같은 패턴을 추가해 하위 템플릿 파일들이 실제로
unignore 되게 수정하세요 (기존에 ".idea/" 전체를 무시하는 규칙이 있으면 해당 규칙 이후에 이 예외들을 배치하세요).
There was a problem hiding this comment.
계속 ignore되지 않고 잘 예외처리 되어 이미 깃에 커밋했습니다.
There was a problem hiding this comment.
@ByunDohwi, 확인해 주셔서 감사합니다! 현재 .gitignore 설정에서 .idea/*로 상위 디렉터리를 무시하고 있기 때문에 !.idea/fileTemplates 패턴만으로도 해당 디렉터리 및 하위 파일들이 올바르게 예외 처리되는 것을 확인하셨군요. 기존 설정 그대로 유지해도 문제없겠습니다. 🐇
| baseline-on-migrate: true | ||
| baseline-version: 1 |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
Redgate Flyway 공식 문서에서 baselineOnMigrate의 동작과 "removes the safety net" 경고 문구를 확인해 주세요.
💡 Result:
Redgate Flyway 공식 문서에 따르면, baselineOnMigrate는 migrate 명령 실행 시 스키마가 비어 있지 않고 schema history table이 없을 때 자동으로 baseline을 호출하는 설정입니다[1][2]. 이 설정을 활성화하면 baselineVersion으로 스키마를 baseline한 후 해당 버전 이상의 마이그레이션만 적용합니다[1]. 이는 기존 DB를 가진 초기 프로덕션 배포에서 별도의 baseline 단계를 생략하는 편의 기능입니다[1]. 문서에는 "Be careful when enabling this as it removes the safety net that ensures Flyway does not migrate the wrong database in case of a configuration mistake!"라는 경고 문구가 명시되어 있습니다[1][2]. 이는 구성 오류로 잘못된 데이터베이스에 마이그레이션이 적용되는 것을 방지하는 안전 장치를 제거한다는 의미입니다. 기본값은 false이며, CLI 예시: flyway -baselineOnMigrate=true migrate[1].
Citations:
- 1: https://documentation.red-gate.com/flyway/reference/configuration/flyway-namespace/flyway-baseline-on-migrate-setting
- 2: https://documentation.red-gate.com/fd/flyway-baseline-on-migrate-setting-277578974.html
🏁 Script executed:
cat -n src/main/resources/application.yaml | sed -n '50,65p'Repository: DSM-PICK/PiCK_CORE_SERVER
Length of output: 647
🏁 Script executed:
find . -name "application*.yaml" -o -name "application*.yml" | head -20Repository: DSM-PICK/PiCK_CORE_SERVER
Length of output: 107
baseline-on-migrate 상시 활성화는 운영 안전장치를 약화시킵니다.
Flyway 공식 문서는 baselineOnMigrate 활성화 시 "Be careful when enabling this as it removes the safety net that ensures Flyway does not migrate the wrong database in case of a configuration mistake!"라고 명시하고 있습니다. 현재 코드에서 이 옵션이 true로 하드코딩되어 있어, 히스토리 테이블이 없는 비어있지 않은 DB를 자동 baseline 처리하면서 잘못된 대상 DB를 조기에 감지하기 어렵습니다. 기본값(false)을 유지하고 필요한 환경에서만 명시적으로 활성화하는 편이 안전합니다.
🔧 제안 수정
flyway:
enabled: true
- baseline-on-migrate: true
+ baseline-on-migrate: ${FLYWAY_BASELINE_ON_MIGRATE:false}
baseline-version: 1
locations:
- classpath:db/migration📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| baseline-on-migrate: true | |
| baseline-version: 1 | |
| baseline-on-migrate: ${FLYWAY_BASELINE_ON_MIGRATE:false} | |
| baseline-version: 1 |
🤖 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 55 - 56, The Flyway setting
baseline-on-migrate is hardcoded true which weakens safety; change
baseline-on-migrate to false (or remove the key to use default false) in
application.yaml and only enable it explicitly per environment where needed, and
keep baseline-version as-is if used; ensure any environment-specific activation
is done via profile-specific YAML or environment variables rather than the
global application.yaml.
There was a problem hiding this comment.
이미 DB가 존재하는 상황에서 추가하는 부분이기 때문에 첫 도입시에는 baseline-on-migrate: true가 필요합니다. flyway 적용 후 false로 다시 변경하겠습니다.
There was a problem hiding this comment.
@ByunDohwi, 말씀하신 내용이 맞습니다. 기존 DB에 Flyway를 처음 도입할 때는 flyway_schema_history 테이블이 없는 비어있지 않은 스키마를 처리하기 위해 baseline-on-migrate: true가 필요합니다.
다만 초기 적용 이후 false로 되돌리는 작업이 누락되지 않도록 별도 이슈나 TODO로 트래킹해 두시길 권장드립니다. 혹시 지금 바로 추적용 이슈를 생성해 드릴까요?
(๑・ω・๑) 🐇
DB 형상관리 툴인 flyway를 적용하였습니다.
파일 형식은
V{생성일의 년월일시분}__{변경 내용}.sql
입니다.
관련된 상세한 사항은 노션 백엔드 Docs에 적어놓았으니 읽어주세요.
Summary by CodeRabbit
릴리스 노트