Skip to content

feat: DB 마이그레이션 스크립트 추가#344

Merged
eunseo9311 merged 5 commits intodevelopfrom
feature/#343-db-migration
Feb 14, 2026
Merged

feat: DB 마이그레이션 스크립트 추가#344
eunseo9311 merged 5 commits intodevelopfrom
feature/#343-db-migration

Conversation

@eunseo9311
Copy link
Copy Markdown
Contributor

About

  • V1: 베이스라인 스키마 정의
  • V2: PK/FK 타입 정렬 (int → bigint)
  • V3: varchar → enum 타입 변환
  • V4: 제약조건 및 기본값 추가
  • 검증 SQL 및 마이그레이션 가이드 문서 추가

#️⃣ Issue Number

#343

📝 요약(Summary)

💬 공유사항 to 리뷰어

  • 제 로컬에서 정상적으로 작업이 되는 것을 확인했습니다.
    푸름님과 용준님의 로컬에서 작업되는지 확인해주셨으면 합니다.
  • 두 분의 확인을 받고 나서 dev -> prod 순서로 변경하려고 합니다.

✅ PR Checklist

PR이 다음 요구 사항을 충족하는지 확인하세요.

  • 커밋 메시지 컨벤션에 맞게 작성했습니다.
  • 변경 사항에 대한 테스트를 했습니다.(버그 수정/기능에 대한 테스트).

- V1: 베이스라인 스키마 정의
- V2: PK/FK 타입 정렬 (int → bigint)
- V3: varchar → enum 타입 변환
- V4: 제약조건 및 기본값 추가
- 검증 SQL 및 마이그레이션 가이드 문서 추가
@eunseo9311 eunseo9311 self-assigned this Feb 7, 2026
@eunseo9311 eunseo9311 added the refactoring 리팩토링 label Feb 7, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @eunseo9311, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

이 PR은 데이터베이스 스키마를 체계적으로 관리하고 개선하기 위한 Flyway 마이그레이션 스크립트들을 도입합니다. 주요 변경사항으로는 기본 키와 외래 키의 데이터 타입을 bigint로 표준화하고, 여러 varchar 컬럼을 enum 타입으로 전환하여 데이터 유효성을 높이는 것입니다. 또한, 필수적인 제약조건과 기본값을 추가하여 데이터 모델의 견고함을 향상시켰습니다. 이 변경사항들은 개발 및 운영 환경에서 데이터베이스 스키마를 안전하고 효율적으로 업데이트할 수 있도록 지원하며, 상세한 가이드와 검증 도구를 통해 마이그레이션 과정의 안정성을 보장합니다.

Highlights

  • DB 마이그레이션 스크립트 추가: Flyway를 사용하여 데이터베이스 스키마 변경을 관리하기 위한 V1부터 V4까지의 마이그레이션 스크립트가 추가되었습니다.
  • PK/FK 타입 정렬: V2 스크립트를 통해 int 타입의 PK/FK 컬럼들이 bigint로 통일되어 데이터 일관성과 확장성을 확보했습니다.
  • varchar 컬럼 enum 타입 변환: V3 스크립트에서 meal, menu, user, inquiry, report 테이블의 varchar 타입 컬럼들을 enum 타입으로 변환하여 데이터 무결성을 강화하고 저장 효율을 높였습니다.
  • 제약조건 및 기본값 추가: V4 스크립트를 통해 NOT NULL 제약조건, 기본값 설정, rating 타입 통일, college.nameUNIQUE 제약조건이 추가되었습니다.
  • 마이그레이션 가이드 및 검증 스크립트 제공: 안전한 마이그레이션을 위해 상세한 가이드 문서(MIGRATION_GUIDE.md)와 데이터 검증 스크립트(run_validation.sh, validate_enum_data.sql, validate_simple.sql)가 함께 추가되었습니다.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • MIGRATION_GUIDE.md
    • DB 마이그레이션 실행을 위한 상세 가이드 문서 추가
    • 사전 준비, Dev/Prod 환경 마이그레이션 절차, 검증 방법, 주의사항, 문제 발생 시 해결책 포함
  • check_fk_constraints.sql
    • 특정 테이블(department, partnership)의 FK 제약조건 이름을 확인하는 SQL 스크립트 추가
  • run_validation.sh
    • enum 데이터 변환 전 데이터 검증을 자동화하는 쉘 스크립트 추가
    • 사용자로부터 환경 및 DB 접속 정보를 입력받아 validate_enum_data.sql 실행
  • src/main/resources/db/migration/V1__baseline.sql
    • 초기 데이터베이스 스키마 정의를 위한 베이스라인 SQL 스크립트 추가
    • 주요 테이블(college, department, meal, menu, user 등) 생성
  • src/main/resources/db/migration/V2__align_pk_and_fk_types.sql
    • PK/FK 컬럼의 데이터 타입을 int에서 bigint로 변경하는 마이그레이션 스크립트 추가
    • FK 제약조건을 일시적으로 해제하고 다시 설정하는 로직 포함
  • src/main/resources/db/migration/V3__convert_varchar_to_enum.sql
    • 여러 테이블의 varchar 컬럼을 enum 타입으로 변환하는 마이그레이션 스크립트 추가
    • 변환 전 데이터 검증의 중요성 강조
  • src/main/resources/db/migration/V4__add_constraints_and_defaults.sql
    • 테이블에 NOT NULL 제약조건, 기본값, UNIQUE 제약조건을 추가하는 마이그레이션 스크립트 추가
    • review.rating 컬럼의 타입을 INT로 통일
  • validate_enum_data.sql
    • varchar에서 enum으로 변환하기 전, 기존 데이터가 enum 허용값에 포함되는지 검증하는 SQL 스크립트 추가
    • 각 테이블의 enum 관련 컬럼에 대한 불일치 데이터 및 전체 데이터 분포 확인 쿼리 포함
  • validate_simple.sql
    • enum 변환 전 간단하게 불일치 데이터를 찾는 SQL 스크립트 추가
    • DB 클라이언트에서 직접 실행하여 결과를 확인할 수 있도록 안내
Activity
  • 작성자는 로컬 환경에서 변경 사항이 정상적으로 작동함을 확인했습니다.
  • 작성자는 푸름님과 용준님에게 로컬 환경에서의 추가 검증을 요청했습니다.
  • 작성자는 리뷰어들의 확인을 받은 후 개발(dev) 환경에서 운영(prod) 환경 순서로 변경 사항을 적용할 계획입니다.
  • 작성자는 커밋 메시지 컨벤션을 준수했으며, 버그 수정 및 기능에 대한 테스트를 완료했습니다.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


DB 스키마 변경, 타입 맞추고 제약 걸어, 데이터는 안전히.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

DB 마이그레이션 스크립트와 상세한 가이드를 추가해주셔서 감사합니다. 전반적으로 매우 꼼꼼하게 작업되었으며, 특히 검증 스크립트와 문제 해결 가이드를 포함한 점이 인상적입니다. 리뷰 결과, 몇몇 스크립트에서 마이그레이션 실패를 유발할 수 있는 부분과 잠재적인 데이터 정합성 문제를 발견했습니다. run_validation.sh 스크립트의 결과 파일명 생성 로직, V4 스크립트의 중복된 UNIQUE 제약조건 추가, 그리고 V2 스크립트의 NOT NULL 제약조건 변경에 대한 수정이 필요해 보입니다. 자세한 내용은 각 파일의 리뷰 코멘트를 참고해주세요.

Comment thread src/main/resources/db/migration/V4__add_constraints_and_defaults.sql Outdated
Comment thread src/main/resources/db/migration/V2__align_pk_and_fk_types.sql
Comment thread run_validation.sh Outdated
eunseo9311 and others added 3 commits February 7, 2026 18:14
V1에 이미 college.name의 UNIQUE 제약조건이 존재하므로
V4에서 중복 추가하는 부분 제거
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Copy link
Copy Markdown
Collaborator

@yongjun0511 yongjun0511 left a comment

Choose a reason for hiding this comment

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

꼼꼼히 작업해 주셔서 감사합니다! 고생 많으셨어요!!
시간이 없어서 실행은 해보지 못했지만.. 큰 문제는 없어 보입니다. 백업을 떠놓고 하면 괜찮을거예요!

fyi) 추가적으로, 만약 마이그레이션이 실패한 경우.
DB 뿐만 아니라 서비스 자체가 죽을 수 있어요. DB를 복구한 이후에 revert후 재배포를 실행해 주어야 할 수 있습니다. ( 새벽에 진행을 하면 유저가 많이 없을거고 잠시 죽어 있어도 괜찮으니 너무 큰 걱정은 하지 마세요 )

Q. mysql 스냅샷 복구 같은 경우는 RDS에 있는 거라 스크립트로 실행이 되는지 확신이 있지는 않네요. 잘 안되면 aws cli에서 할 수 있어요. (RDS 메뉴에서)

Q. 혹시 yml 관련 변경 사항은 필요없이 baseline 실행이 가능한걸까요 (저도 yml 변화 없이 해본적이 없어서)!

  flyway:
    enabled: true
    baseline-on-migrate: true
    locations:

요런 것들이 딱히 안보여서요!

Copy link
Copy Markdown
Member

@pooreumjung pooreumjung left a comment

Choose a reason for hiding this comment

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

고생하셨습니당
application.yml은 따로 설정이 필요 없을까요?

@eunseo9311
Copy link
Copy Markdown
Contributor Author

네 감사합니다! 용준님이랑 푸름님께서 주신 피드백 바탕으로 수정해보겠습니다!

Copy link
Copy Markdown
Member

@pooreumjung pooreumjung left a comment

Choose a reason for hiding this comment

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

application.yml 설정 확인했습니다~

@eunseo9311 eunseo9311 merged commit d66e77a into develop Feb 14, 2026
@eunseo9311 eunseo9311 deleted the feature/#343-db-migration branch February 14, 2026 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactoring 리팩토링

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants