Skip to content

Conversation

@wjdwnsdnjs13
Copy link
Member

@wjdwnsdnjs13 wjdwnsdnjs13 commented Jul 24, 2025

Summary

Tasks

  • Schema 파일 최신화
  • init.sql 추가

ETC

각자 맡은 도메인의 데이터 확인해주세요.
insert는 제대로 되지만, 도메인 정책 상 나올 수 없는 케이스는 막을 수가 없고 제가 전부 체크할 수가 없어서 각자 도메인 정책에 따라서 수정해주셔야 할 거 같아요.

정산 쪽도 수정중입니다!

Screenshot

Summary by CodeRabbit

  • 신규 기능

    • 데이터베이스에 17기 코호트, 4개 팀, 20명 멤버(4명 관리자 포함) 등 실제 운영 환경과 유사한 다양한 초기 데이터를 추가했습니다.
    • 권한, 정산 계좌, 정산, 모임, 영수증, OAuth, 리프레시 토큰 등 여러 도메인 엔티티와 관계가 포함되었습니다.
  • 리팩터링

    • 데이터베이스 스키마가 표준화되었으며, 컬럼명과 테이블명이 일관성 있게 정리되고 추가 및 변경되었습니다.
    • 컬럼 타입이 통일되고 외래키 및 유니크 제약조건이 명확히 추가되어 데이터 무결성이 강화되었습니다.

@wjdwnsdnjs13 wjdwnsdnjs13 self-assigned this Jul 24, 2025
@wjdwnsdnjs13 wjdwnsdnjs13 linked an issue Jul 24, 2025 that may be closed by this pull request
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 24, 2025

"""

Walkthrough

이 변경사항은 데이터베이스 초기화 및 시딩을 위한 SQL 스크립트 세트를 도입 및 갱신합니다. 스키마 정의(schema.sql)가 표준화되고, 엔티티별 시딩 데이터(init.sql, init-250724.sql)가 추가되어 다양한 도메인 테이블에 초기값이 삽입됩니다. 테이블 구조, 컬럼명, 타입, 제약조건 등이 전반적으로 정비되었습니다.

Changes

파일(들) 변경 요약
.../db/schema.sql 테이블 생성문 전면 교체: 컬럼명/타입 표준화, 외래키 및 유니크 제약조건 추가, 일부 테이블/컬럼명 변경 및 구조 개선
.../db/init.sql
.../db/init-250724.sql
여러 도메인 테이블(cohorts, teams, members 등)에 대한 대량의 시딩 데이터 삽입 스크립트 추가

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~40분

  • 스키마 변경이 전면적이며, 테이블 구조와 제약조건, 컬럼 타입 등 다수의 요소가 수정됨
  • 시딩 데이터가 방대하고, 테이블 간 관계 및 데이터 일관성 확인 필요
  • 리뷰 시 논리적/구조적 검증에 상당한 시간 소요 예상
    """

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2bf4ffb and 7cd3bb4.

📒 Files selected for processing (1)
  • src/main/resources/db/init-250724.sql (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/resources/db/init-250724.sql
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: compile
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/#81

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

DB 스키마를 최신화하고 초기 데이터 시딩을 위한 SQL 파일들을 추가하는 PR입니다. 개발 환경에서 테스트를 위한 샘플 데이터를 제공하여 각 도메인별 기능 검증이 가능하도록 합니다.

  • 데이터베이스 스키마 파일을 최신 엔터티 구조에 맞게 업데이트
  • 기본적인 테스트 데이터를 포함한 init.sql 파일 추가
  • 더 상세한 17기 기준 샘플 데이터를 포함한 init-250724.sql 파일 추가

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/main/resources/db/schema.sql 기존 스키마를 최신 엔터티 구조에 맞게 전면 개편하고 외래키 제약조건 추가
src/main/resources/db/init.sql 각 테이블별 기본 테스트 데이터 추가
src/main/resources/db/init-250724.sql 17기 기준 20명의 멤버와 상세한 도메인별 샘플 데이터 추가
sequenceDiagram
    participant Dev as 개발자
    participant DB as 데이터베이스
    participant App as 애플리케이션
    
    Dev->>DB: schema.sql 실행
    Note over DB: 테이블 구조 생성
    Dev->>DB: init.sql 또는 init-250724.sql 실행
    Note over DB: 샘플 데이터 삽입
    App->>DB: 도메인별 기능 테스트
    DB-->>App: 시딩된 데이터 반환
Loading
Comments suppressed due to low confidence (2)

src/main/resources/db/schema.sql:147

  • [nitpick] refresh_tokens 테이블에서 TEXT 타입이 대문자로 사용되었는데, 다른 테이블들에서는 varchar(255) 등 소문자로 일관되게 사용되고 있습니다. 코틀린과 SQL 스타일 가이드에 따라 text로 소문자를 사용하는 것이 좋겠습니다. 기존 코드와 비교했을 때 대소문자 통일성이 부족합니다.
                                              token TEXT,

(18, 9, 18, b'0', b'1', '2024-01-07 10:00:00', '2024-01-07 10:00:00', NULL, NULL),
(19, 10, 19, b'1', b'1', '2024-01-08 10:00:00', '2024-01-08 10:00:00', NULL, NULL),
(20, 10, 20, b'0', b'0', '2024-01-08 10:00:00', '2024-01-08 10:00:00', NULL, NULL),
(21, 10, 20, b'0', b'0', '2024-01-08 10:00:00', '2024-01-08 10:00:00', NULL, NULL),
Copy link

Copilot AI Jul 24, 2025

Choose a reason for hiding this comment

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

gathering_members 테이블에서 167-182번 라인에 동일한 member_id(20)가 여러 번 반복되고, 같은 날짜와 시간이 계속 사용되고 있습니다. 이는 실제 데이터와 차이가 있고 유지보수가 어렵습니다. 각각 다른 멤버들과 다른 시간대를 사용하거나, 실제 gathering_id에 맞는 적절한 멤버들을 배치하는 것이 좋겠습니다. 현재 방식은 데이터의 의미를 파악하기 어렵고 테스트 시 혼란을 야기할 수 있습니다.

Copilot generated this review using guidance from repository custom instructions.
Copy link
Contributor

@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: 5

🧹 Nitpick comments (3)
src/main/resources/db/init.sql (1)

46-53: 계좌정보 예시 데이터 최소 검증 필요

bank_name, bill_account_value 값에 실제 포맷(숫자·‘-’) 검증 로직이 스키마/애플리케이션 레이어에 존재하지 않으면, 잘못된 형식의 데이터가 그대로 유입될 수 있습니다.
도메인 제약조건(길이, 정규식 등)을 추가로 고려해 주세요.

src/main/resources/db/init-250724.sql (1)

145-182: 과도한 중복 Gathering Member 레코드

gathering_id = 20, member_id = 20 조합이 10회 이상 반복됩니다.
기능적으로는 PK(gathering_member_id)로 구별되지만 실제 서비스 데이터로 사용하기엔 비현실적이며, 통계/로직 오동작의 가능성이 있습니다.
테스트용 중복인지, 의도된 시나리오인지 다시 검토해주세요.

src/main/resources/db/schema.sql (1)

185-187: Gathering Receipts 에 단일 영수증만 허용됨

UKm6ed9w2qvce73flgh19rskk9t (gathering_id) 제약은 한 회식당 영수증 1건만 허용합니다.
서비스 정책상 여러 영수증을 지원해야 한다면 UNIQUE 제약을 제거하고 인덱스로만 유지하세요.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6fc23c4 and 59ab80d.

📒 Files selected for processing (3)
  • src/main/resources/db/init-250724.sql (1 hunks)
  • src/main/resources/db/init.sql (1 hunks)
  • src/main/resources/db/schema.sql (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: CR
PR: depromeet/dpm-core-server#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-07-21T15:22:12.408Z
Learning: 가장 먼저, 코드 리뷰 시 PR에 대한 요약을 작성하고, 작성된 코드의 시퀀스 다이어그램을 그려서 첨부한다
🔇 Additional comments (1)
src/main/resources/db/init-250724.sql (1)

53-72: ROLE 매핑이 설명과 불일치

주석에는 “운영진은 ROLE_ADMIN, 나머지는 ROLE_USER”라 되어 있으나
member_id 14(운영진) → authority_id = 1(ROLE_USER)
member_id 17
20 → authority_id = 2(ROLE_ADMIN) 로 역으로 입력되어 있습니다.
도메인 정책을 따른 값으로 재확인 바랍니다.

Comment on lines +1 to +10
-- Cohorts (기수)
INSERT INTO cohorts (cohort_id, created_at, updated_at, value) VALUES
(1, 1710000000, 1710000000, '17'),
(2, 1700000000, 1700000000, '16');

-- Teams (팀)
INSERT INTO teams (team_id, cohort_id, number, created_at, updated_at) VALUES
(1, 1, 1, 1710000000, 1710000000),
(2, 1, 2, 1710000000, 1710000000);

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

초기화 스크립트 간 PK 충돌 위험

init.sql은 PK 값이 1부터 고정되어 있습니다. 동일한 PK 값을 갖는 init-250724.sql도 PR에 포함되어 있어 두 스크립트를 연속 실행하면 PRIMARY KEY duplication 오류가 발생합니다.
운영·로컬 환경별로 하나만 실행되도록 분리하거나, INSERT ... ON DUPLICATE KEY IGNORE/시퀀스 리셋 전략을 명확히 정의해주세요.

🤖 Prompt for AI Agents
In src/main/resources/db/init.sql lines 1 to 10, the primary key values for
cohorts and teams start fixed at 1, which conflicts with another script
init-250724.sql causing duplicate key errors when both run sequentially. To fix
this, modify the insert statements to either use INSERT ... ON DUPLICATE KEY
IGNORE syntax or implement a sequence reset strategy to avoid PK collisions.
Alternatively, separate the scripts so only one runs per environment, ensuring
no overlapping PK values.

Comment on lines +45 to +52
create table if not exists cohorts (
cohort_id bigint not null auto_increment,
created_at bigint not null,
updated_at bigint not null,
value varchar(255) not null,
primary key (cohort_id)
) engine=InnoDB;

Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Timestamp 타입 불일치(Cohorts)

cohorts.created_at/updated_atbigint, 대부분 다른 테이블은 datetime(6)을 사용합니다.
같은 의미의 컬럼은 동일 타입으로 맞춰야 쿼리·ORM 매핑·비교 연산에서 혼선을 줄일 수 있습니다.

🤖 Prompt for AI Agents
In src/main/resources/db/schema.sql around lines 45 to 52, the created_at and
updated_at columns in the cohorts table are defined as bigint, while most other
tables use datetime(6) for these timestamp fields. To maintain consistency and
avoid confusion in queries, ORM mapping, and comparisons, change the data types
of cohorts.created_at and cohorts.updated_at from bigint to datetime(6).

Comment on lines +160 to +171
create table if not exists sessions (
is_online bit not null,
week integer not null,
attendance_start datetime(6) not null,
cohort_id bigint not null,
date datetime(6) not null,
session_id bigint not null auto_increment,
attendance_code varchar(255) not null,
event_name varchar(255),
place varchar(255),
primary key (session_id)
) engine=InnoDB;
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

참조 무결성 제약 부족

attendances, member_authorities, member_teams 등 다수 테이블이 외래키 없이 정의되어 있습니다.
데이터 품질을 위해 다음 FK 추가를 고려해 주세요.

ALTER TABLE attendances
  ADD FOREIGN KEY (member_id)  REFERENCES members(member_id),
  ADD FOREIGN KEY (session_id) REFERENCES sessions(session_id);
-- 동일 패턴으로 다른 테이블도 추가
🤖 Prompt for AI Agents
In src/main/resources/db/schema.sql around lines 160 to 171, the sessions table
and other related tables like attendances, member_authorities, and member_teams
lack foreign key constraints, which can lead to data integrity issues. To fix
this, add appropriate foreign key constraints linking columns such as member_id
and session_id in these tables to their referenced primary keys in members and
sessions tables respectively. Use ALTER TABLE statements to define these foreign
keys to enforce referential integrity and improve data quality.

Comment on lines +174 to +179
number integer not null,
cohort_id bigint not null,
created_at bigint not null,
team_id bigint not null auto_increment,
updated_at bigint not null,
primary key (team_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Timestamp 타입 불일치(Teams)

teams.created_at/updated_atbigint입니다. 위 코멘트와 동일한 이유로 datetime(6) 사용을 권장합니다.

🤖 Prompt for AI Agents
In src/main/resources/db/schema.sql around lines 174 to 179, the columns
created_at and updated_at in the teams table are currently defined as bigint,
which is inconsistent with the recommended datetime(6) type. Change the data
types of created_at and updated_at from bigint to datetime(6) to ensure proper
timestamp handling and consistency with other tables.

Copy link
Member

@LeeHanEum LeeHanEum left a comment

Choose a reason for hiding this comment

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

LGTM 👍👍

Copy link
Member

@its-sky its-sky left a comment

Choose a reason for hiding this comment

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

LGTM!!

) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
create table if not exists attendances (
attended_at datetime(6),
id bigint not null auto_increment,
Copy link
Member

Choose a reason for hiding this comment

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

컬럼명 session_id로 부탁드려요~

Copy link
Member Author

Choose a reason for hiding this comment

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

이거 시딩 파일은 1차 끝나고 저희 만나서 얘기해보고 정책 맞추면 어떨까 싶어용 ㅎㅎ

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DB 시딩 파일 추가

4 participants