Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor/#152 DDL 및 DML 최신화 #153

Merged
merged 4 commits into from
Dec 31, 2024
Merged

Conversation

minjo-on
Copy link
Contributor

@minjo-on minjo-on commented Dec 31, 2024

Summary

Tasks

  • file_entity schema에 extension, file_size 추가
  • 추가 더미데이터 생성

To Reviewer

Hibernate가 생성한 테이블과 schema로 생성한 테이블 둘다 에러 발생하지 않도록 DML 수정했습니다. 혹시 수정 필요한 부분 있으면 말씀해주세용😁

@minjo-on minjo-on added the 🔨refactor refactoring code label Dec 31, 2024
@minjo-on minjo-on requested a review from a team December 31, 2024 05:24
@minjo-on minjo-on self-assigned this Dec 31, 2024
@minjo-on minjo-on linked an issue Dec 31, 2024 that may be closed by this pull request
1 task
Copy link
Contributor

coderabbitai bot commented Dec 31, 2024

Walkthrough

이 풀 리퀘스트는 데이터베이스 스키마와 초기 데이터 파일을 업데이트합니다. data.sqlschema.sql 파일에서 여러 테이블의 구조를 변경하고 새로운 열을 추가했습니다. 주요 변경 사항은 타임스탬프 필드 추가, 파일 엔티티에 확장자와 파일 크기 열 도입, 그리고 새로운 댓글 테이블 생성을 포함합니다.

Changes

파일 변경 요약
aics-api/src/main/resources/db/schema.sql file_entity 테이블에 file_size, extension 열 추가
aics-api/src/main/resources/db/data.sql 여러 테이블에 created_at, updated_at 열 추가, 새 데이터 항목 삽입, 새 comment 테이블 생성

Assessment against linked issues

목표 해결 여부 설명
DDL 및 DML 최신화 [#152]
스키마 구조 변경 대응 [#152]
목 데이터 작성 [#152] 각 테이블에 5-10개의 데이터 항목 추가

Possibly related PRs

  • 현재 관련된 풀 리퀘스트가 없습니다.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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. (Beta)
  • @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

Test Coverage Report

Overall Project 88.86% 🍏

There is no coverage information present for the Files changed

Copy link

codecov bot commented Dec 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Impacted file tree graph

@@            Coverage Diff             @@
##             develop     #153   +/-   ##
==========================================
  Coverage      83.95%   83.95%           
  Complexity        79       79           
==========================================
  Files             21       21           
  Lines            293      293           
  Branches           4        4           
==========================================
  Hits             246      246           
  Misses            41       41           
  Partials           6        6           

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ee48655...b64ac39. Read the comment docs.

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: 3

🧹 Nitpick comments (2)
aics-api/src/main/resources/db/schema.sql (1)

Line range hint 1-150: 인덱스 추가 검토 필요

성능 최적화를 위해 다음 인덱스 추가를 검토해주세요:

  1. file_entity: extension 컬럼 (파일 타입별 조회 최적화)
  2. post: category, created_at 복합 인덱스 (카테고리별 최신 글 조회)
  3. comment: post_id, created_at 복합 인덱스 (게시글별 댓글 조회)
aics-api/src/main/resources/db/data.sql (1)

1-112: 테스트 데이터 다양성 개선 필요

더 다양한 테스트 케이스를 위해 다음 데이터 추가를 검토해주세요:

  1. 삭제된 데이터 (deleted_at 값이 있는 레코드)
  2. 다양한 시간대의 created_at, updated_at
  3. 특수 문자나 이모지가 포함된 콘텐츠
  4. 최대 길이에 가까운 텍스트 데이터
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between ee48655 and b64ac39.

📒 Files selected for processing (2)
  • aics-api/src/main/resources/db/data.sql (1 hunks)
  • aics-api/src/main/resources/db/schema.sql (1 hunks)

Comment on lines +53 to +54
file_size VARCHAR(10) NOT NULL,
extension VARCHAR(10) NOT NULL,
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

file_size 컬럼 타입 개선 필요

다음과 같은 개선사항을 제안드립니다:

  1. file_size 컬럼을 BIGINT로 변경하여 바이트 단위의 정확한 파일 크기를 저장
  2. extension 컬럼의 길이를 VARCHAR(10)에서 VARCHAR(5)로 축소 (일반적인 파일 확장자 길이 고려)
-    file_size     VARCHAR(10) NOT NULL,
-    extension     VARCHAR(10) NOT NULL,
+    file_size     BIGINT NOT NULL,
+    extension     VARCHAR(5) NOT NULL,
📝 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.

Suggested change
file_size VARCHAR(10) NOT NULL,
extension VARCHAR(10) NOT NULL,
file_size BIGINT NOT NULL,
extension VARCHAR(5) NOT NULL,

Comment on lines 25 to +35
INSERT INTO "user" (id, password, name, email, phone, major, role, created_at, updated_at)
VALUES ('202412346', '$2a$10$NkQj6yk0Xh4QhKevjrOkouQBymXUgpKqmHQFnTUKRaVhDrRZf5OTG', '이한음', 'haneum@kgu.ac.kr',
'010-2345-6789', 'AIT', 'SUPER', CURRENT_TIMESTAMP,
CURRENT_TIMESTAMP),
('202412347', '$2a$10$NkQj6yk0Xh4QhKevjrOkouQBymXUgpKqmHQFnTUKRaVhDrRZf5OTG', '박민준', 'minjun@kyonggi.ac.kr',
'010-1234-8765', 'CSE', 'USER', CURRENT_TIMESTAMP,
CURRENT_TIMESTAMP),
('202412348', '$2a$10$NkQj6yk0Xh4QhKevjrOkouQBymXUgpKqmHQFnTUKRaVhDrRZf5OTG', '이신행', 'shinhaeng@kyonggi.ac.kr',
'010-3456-7890', 'SSS', 'ADMIN', CURRENT_TIMESTAMP,
CURRENT_TIMESTAMP);
VALUES ('202412346', '$2a$10$NkQj6yk0Xh4QhKevjrOkouQBymXUgpKqmHQFnTUKRaVhDrRZf5OTG',
'이한음', 'haneum@kgu.ac.kr', '010-2345-6789', 'AIT', 'SUPER', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
('202412347', '$2a$10$NkQj6yk0Xh4QhKevjrOkouQBymXUgpKqmHQFnTUKRaVhDrRZf5OTG',
'박민준', 'minjun@kyonggi.ac.kr', '010-1234-8765', 'CSE', 'USER', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
('202412348', '$2a$10$NkQj6yk0Xh4QhKevjrOkouQBymXUgpKqmHQFnTUKRaVhDrRZf5OTG',
'이신행', 'shinhaeng@kyonggi.ac.kr', '010-3456-7890', 'SSS', 'ADMIN', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
('202412349', '$2a$10$NkQj6yk0Xh4QhKevjrOkouQBymXUgpKqmHQFnTUKRaVhDrRZf5OTG',
'홍길동', 'hong@kyonggi.ac.kr', '010-5678-1234', 'CSE', 'USER', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
('202412350', '$2a$10$NkQj6yk0Xh4QhKevjrOkouQBymXUgpKqmHQFnTUKRaVhDrRZf5OTG',
'김철수', 'kim@kyonggi.ac.kr', '010-8765-4321', 'CSE', 'SUPER', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);
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

테스트 데이터 보안 강화 필요

  1. 실제 이메일 도메인 사용 대신 예시 도메인(example.com) 사용 권장
  2. 전화번호는 가상의 번호로 대체 필요
  3. 비밀번호 해시값을 테스트용 문자열로 대체 권장

Comment on lines +46 to +56
INSERT INTO file_entity (logical_name, physical_path, extension, file_size, created_at, updated_at)
VALUES ('학과소개파일', '/files/about/dept_intro.pdf', 'pdf', '12345', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
('교육활동파일', '/files/edu/activities.pdf', 'pdf', '23456', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
('커리큘럼파일', '/files/edu/curriculum.pdf', 'pdf', '34567', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
('연구 성과 이미지', '/files/carousel/research_results.jpg', 'jpg', '45678', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
('학과 행사 이미지', '/files/carousel/department_event.jpg', 'jpg', '56789', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
('동아리 활동 이미지', '/files/carousel/club_activity.jpg', 'jpg', '67890', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
('캠퍼스 전경 이미지', '/files/carousel/campus_view.jpg', 'jpg', '78901', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
('졸업식 이미지', '/files/carousel/graduation_ceremony.jpg', 'jpg', '89012', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
('취업 설명회 자료', '/files/employment/info.pdf', 'pdf', '54321', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
('연구 프로젝트 소개', '/files/research/project_intro.pdf', 'pdf', '65432', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);
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

파일 데이터 개선 필요

  1. file_size 값들이 문자열 형태로 저장되어 있습니다. 컬럼 타입을 BIGINT로 변경 시 숫자로 변환 필요
  2. physical_path에 대한 보안 검토 필요:
    • 경로 주입 공격 방지
    • 파일 시스템 접근 제한
    • 실제 파일 존재 여부 확인
-VALUES ('학과소개파일', '/files/about/dept_intro.pdf', 'pdf', '12345', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
+VALUES ('학과소개파일', '/files/about/dept_intro.pdf', 'pdf', 12345, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),

Committable suggestion skipped: line range outside the PR's diff.

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 👍 개발 DB 데이터 삭제 후 새로운 데이터셋 삽입 부탁드려요~

@minjo-on minjo-on merged commit 2a7de92 into develop Dec 31, 2024
5 checks passed
@minjo-on minjo-on deleted the refactor/#152-ddl-dml-update branch December 31, 2024 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨refactor refactoring code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DDL 및 DML 최신화
2 participants