Repository navigation
Conversation
staging·prod 의 migrate 를 apps/migration one-shot 모듈로 옮기고 api 는 validate 만 한다. 환경별로 나눈 수동 워크플로(deploy-migration-staging/prod)가 이미지를 올리고 GitOps Job 을 갱신하면 ArgoCD 가 Job 을 실행한다. prod 는 main, staging 은 stg·main 에서만 실행한다. 마이그레이션만 바뀐 main push 는 api prod 를 재배포하지 않는다. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 18 minutes. View limit details
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. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
배경
공유 DB 의 migrate 는 api 만 기동 시점에 수행하고 admin·batch 는 validate 만 합니다. 그래서 admin 이나 Workflow 가 쓸 컬럼 하나를 추가해도 운영 api 를 재배포해야 했고, 그 사이 main 에 쌓인 api 변경까지 같이 나갔습니다. migrate 실행 주체를 api 에서 떼어 내 스키마 변경을 앱 배포와 따로 적용할 수 있게 합니다. SQL 파일은 지금처럼
modules/postgres에 둡니다.Sprint: BACKEND-314
변경 내용
apps/migrationone-shot 모듈 추가 ::modules:postgres+:modules:jasypt만 의존하고 migrate 후 종료함. 기존 ENC 접속 정보와 jasypt Secret 을 그대로 씀bootRun과 E2E 는 그대로deploy-migration-staging.yml(stg·main),deploy-migration-prod.yml(main). 환경·ref 입력이 없어 다른 환경을 고를 수 없고, 허용 밖 브랜치는 이미지 빌드 전에 실패함neki-migration-<sha>-<run>)·이미지를 바꾸고, ArgoCD auto-sync 가 새 Job 을 실행하고 이전 Job 을 prune 함. Job template 은 바꿀 수 없어 실행마다 이름을 바꿈deploy-api-prod.yml에paths-ignore추가 : 마이그레이션 SQL·apps/migration·마이그레이션 워크플로만 바뀐 push 는 api 를 재배포하지 않음flowchart LR A[마이그레이션 PR 머지] --> B[Deploy Migration to Staging] B --> C[Deploy Migration to Prod] C --> D[GitOps Job 이름·태그 갱신] D --> E[ArgoCD sync, Job 이 migrate] E --> F[그 스키마를 쓰는 앱 PR 머지·배포]배포 순서 규칙(마이그레이션 PR 분리, 머지 직후 실행)은
.claude/CLAUDE.md에 적었습니다. 실행을 미루면 그사이 main 에 머지된 다른 api 변경도 validate 에서 기동하지 못합니다. 롤링 업데이트라 기존 파드가 계속 서빙합니다.버린 대안 : 스키마 전용 레포(테스트가 SQL 을 직접 읽어 submodule 이 필요), Flyway CLI 공식 이미지(Jasypt 를 못 읽어 평문 DB Secret 이 따로 필요), ArgoCD PreSync hook(hook 은 sync 상태 비교에 들어가지 않아 태그만 바꾼 커밋으로 실행되지 않음).
검증
./gradlew :apps:migration:test1건 통과 : prod 프로필 그대로 새 PostGIS(Testcontainers) DB 에 기동해 미적용 마이그레이션 0건 확인. V35 시드 브랜드는 api·admin 테스트와 같은V34_1테스트 SQL 로 넣음./gradlew spotlessCheck :apps:api:compileKotlin :apps:admin:compileKotlin :apps:batch:compileKotlin :apps:migration:bootJar통과. bootJar 에 postgres·jasypt·flyway·드라이버 포함 확인suspend가 의도대로 바뀌는 것 확인머지 전 확인: GitOps PR(Job 매니페스트)을 먼저 머지해야 워크플로 preflight 가 통과합니다. 첫 실행 뒤 GHCR 패키지
neki-migration을 public 으로 바꿔야 Job 이 이미지를 받을 수 있습니다 (클러스터에 pull secret 없음).🤖 Generated with Claude Code