Skip to content

[fix] users 테이블 version 컬럼 추가#182

Merged
geunyong16 merged 2 commits into
mainfrom
fix/181-add-users-version-column
May 5, 2026
Merged

[fix] users 테이블 version 컬럼 추가#182
geunyong16 merged 2 commits into
mainfrom
fix/181-add-users-version-column

Conversation

@geunyong16
Copy link
Copy Markdown
Collaborator

@geunyong16 geunyong16 commented May 5, 2026

🔖 관련 GitHub Issue

📝 변경 사항

주요 변경 내용

  • users 테이블에 version BIGINT DEFAULT 0 컬럼을 추가하는 Flyway 마이그레이션 파일 생성
    • 파일: V20260505__Add_version_column_to_users.sql

상세 설명

User 엔티티에 JPA Optimistic Locking을 위한 @Version 어노테이션이 추가되었으나, 대응되는 DB 마이그레이션 파일이 누락되어 있었습니다. 이로 인해 운영 서버의 users 테이블에 version 컬럼이 없어 다음과 같은 오류가 발생했습니다.

Caused by: java.sql.SQLSyntaxErrorException: Unknown column 'u1_0.version' in 'field list'

영향 범위는 users 테이블을 조회하는 모든 엔드포인트(로그인 포함)였으며, 사실상 모든 API 요청이 500 Internal Server Error를 반환하는 상태였습니다.

해결 방법

  • BIGINT 타입으로 컬럼 추가 (Java Long 타입과 매핑)
  • DEFAULT 0으로 설정하여 기존 사용자 row의 version 값을 0으로 초기화 (JPA @Version 표준 시작 값)
  • Flyway가 애플리케이션 시작 시 자동으로 마이그레이션을 적용

✅ 체크리스트

  • PR 제목이 형식에 맞는가? (유형: 작업 요약)
  • 코드가 정상적으로 빌드되는가?
  • 새로운 기능에 대한 테스트 코드를 작성했는가? (DB 스키마 마이그레이션이라 해당 없음)
  • 모든 테스트가 통과하는가?
  • 코드 스타일 가이드를 따랐는가?
  • 관련 문서를 업데이트했는가? (해당 없음)

🔗 관련 PR

  • Related to #

Summary by CodeRabbit

릴리스 노트

  • Chores
    • 동시성 업데이트 처리 개선을 위한 데이터베이스 스키마 업데이트

User 엔티티에 추가된 @Version 필드에 대응하는 DB 마이그레이션 누락으로
모든 API 요청이 500 Internal Server Error를 반환하는 문제 해결.

Closes #181
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

Warning

Rate limit exceeded

@geunyong16 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 56 minutes and 19 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d0daae84-2d10-4c9a-9f6c-707ddf3d97c3

📥 Commits

Reviewing files that changed from the base of the PR and between 0578f15 and 2421d90.

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

Walkthrough

users 테이블에 JPA 낙관적 잠금(optimistic locking) 지원을 위한 version 컬럼을 추가하는 데이터베이스 마이그레이션 파일이 생성되었습니다. version 컬럼은 BIGINT 타입이며 기본값은 0입니다.

Changes

데이터베이스 스키마 업데이트

레이어 / 파일 요약
스키마 마이그레이션
src/main/resources/db/migration/V20260505__Add_version_column_to_users.sql
users 테이블에 version 컬럼(BIGINT DEFAULT 0)을 추가하는 Flyway 마이그레이션 파일입니다. User 엔티티의 @Version 필드와 대응하는 데이터베이스 컬럼을 생성합니다.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3분

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목 '[fix] users 테이블 version 컬럼 추가'는 변경사항을 명확하게 요약하며 템플릿 형식 '[유형] 작업 요약'을 올바르게 따르고 있습니다.
Description check ✅ Passed PR 설명이 템플릿의 모든 주요 섹션(관련 이슈, 주요 변경 내용, 상세 설명, 체크리스트)을 완전히 포함하고 있으며 변경 배경과 해결 방법을 상세히 설명하고 있습니다.
Linked Issues check ✅ Passed PR은 연결된 issue #181의 모든 요구사항을 충족합니다: Flyway 마이그레이션 파일을 통해 users 테이블에 version BIGINT DEFAULT 0 컬럼을 추가하여 SQLSyntaxErrorException을 해결하고 모든 API 엔드포인트 복구를 목표로 합니다.
Out of Scope Changes check ✅ Passed PR의 모든 변경사항은 issue #181에 명시된 'version 컬럼 추가'라는 단일 목표에 정확히 제한되어 있으며, 불필요한 추가 변경사항이 없습니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/181-add-users-version-column

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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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/db/migration/V20260505__Add_version_column_to_users.sql`:
- Line 2: The migration adds a version column but omits a NOT NULL constraint;
update the migration so the users table's version column (column name: version)
is non-nullable to satisfy JPA `@Version` requirements by altering the ADD COLUMN
statement to include NOT NULL (or run an ALTER TABLE ... ALTER COLUMN ... SET
NOT NULL after populating defaults), ensuring existing rows are initialized to 0
and the column cannot contain NULL going forward.
🪄 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: 3f98fbc3-38c8-49df-9f4a-5ba53054adae

📥 Commits

Reviewing files that changed from the base of the PR and between f947835 and 0578f15.

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

Comment thread src/main/resources/db/migration/V20260505__Add_version_column_to_users.sql Outdated
JPA @Version 필드는 낙관적 잠금을 위해 항상 non-null이어야 하므로
NOT NULL 제약 조건을 추가. DEFAULT 0이 설정되어 있어 기존 행은
안전하게 0으로 초기화됨.

CodeRabbit 리뷰 반영.
@geunyong16 geunyong16 merged commit cd8cebc into main May 5, 2026
1 of 2 checks passed
@geunyong16 geunyong16 deleted the fix/181-add-users-version-column branch May 5, 2026 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] users 테이블 version 컬럼 누락으로 인한 500 서버 오류

1 participant