Skip to content

[Feat/#]diary entities 추가#18

Open
soyerin0407 wants to merge 1 commit into
developfrom
feat/diary-entity
Open

[Feat/#]diary entities 추가#18
soyerin0407 wants to merge 1 commit into
developfrom
feat/diary-entity

Conversation

@soyerin0407

@soyerin0407 soyerin0407 commented Jul 9, 2026

Copy link
Copy Markdown

📌 PR 제목

[Feat/#14] 다이어리 엔티티 추가

📌 관련 이슈번호

(Closes 키워드가 있어야 PR이 머지되었을 때 이슈가 자동으로 닫힌다)

  • Closes #이슈 번호

📌 PR 유형

어떤 변경 사항이 있나요?

  • [x ] 새 기능 추가
  • 버그 수정
  • 리팩토링

📌 PR 요약

Diary 도메인의 엔티티 및 모듈을 추가했습니다.

📌 작업 세부 내용

  1. DiaryEntity 추가
  2. DiaryImageEntity 추가
  3. RecommendEntity 및 DiaryType enum 추가
  4. DiariesModule 생성 및 AppModule 등록

📸 스크린샷 (선택)

🔗 참고 자료

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

DiariesModule을 신규 생성하고 app.module.ts에 등록했다. DiaryEntity, DiaryImageEntity, RecommendEntity TypeORM 엔티티와 DiaryType enum을 새로 추가하여 다이어리 관련 테이블 스키마를 정의했다.

Changes

Diaries 모듈 및 엔티티

Layer / File(s) Summary
DiaryType enum 정의
src/diaries/enums/diary-type.enum.ts
QUESTION, FREE 값을 가진 DiaryType enum을 정의한다.
Diary 관련 TypeORM 엔티티 정의
src/diaries/entities/diary.entity.ts, src/diaries/entities/diary-image.entity.ts, src/diaries/entities/recommend.entity.ts
DiaryEntity, DiaryImageEntity, RecommendEntity를 정의하고 각 테이블의 컬럼, 타입, nullable 제약을 설정한다.
DiariesModule 정의 및 앱 등록
src/diaries/diary.module.ts, src/app.module.ts
DiariesModule에서 관련 엔티티를 TypeOrmModule.forFeature로 등록하고 TypeOrmModule을 export하며, 앱 모듈에 DiariesModule을 추가한다.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed 다이어리 엔티티와 모듈 추가라는 변경 사항을 잘 반영한 제목입니다.
Description check ✅ Passed 설명이 Diary 도메인 엔티티와 모듈 추가 내용을 정확히 요약하고 있어 변경 사항과 일치합니다.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/diary-entity

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (3)
src/diaries/entities/diary-image.entity.ts (1)

12-18: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

diaryId 컬럼에 인덱스 누락

다이어리별 이미지 목록을 조회할 때 diaryId로 필터링하게 될 텐데 인덱스가 없습니다. @Index 추가를 권장합니다.

As per path instructions, "필요한 인덱스/유니크 제약이 누락되지 않았는지" 확인이 필요합니다.

♻️ 제안
-import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
+import { Column, Entity, Index, PrimaryGeneratedColumn } from 'typeorm';
 import { SoftDeleteModel } from '../../global/base-model';

 `@Entity`('diary_image')
 export class DiaryImageEntity extends SoftDeleteModel {
   `@PrimaryGeneratedColumn`({
     name: 'diary_image_id',
     type: 'int',
   })
   diaryImageId: number;

+  `@Index`()
   `@Column`({
     name: 'diary_id',
     type: 'int',
     nullable: false,
     comment: '일기 아이디',
   })
   diaryId: number;
🤖 Prompt for 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.

In `@src/diaries/entities/diary-image.entity.ts` around lines 12 - 18, The diary
image entity is missing an index on the `diaryId` field, which is likely used
for filtering image lists by diary. Add an `@Index` on the `DiaryImage` entity
for the `diaryId` property, keeping the existing `@Column` mapping intact, so
lookups via `diaryId` are optimized.

Source: Path instructions

src/diaries/entities/recommend.entity.ts (1)

12-26: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

categoryId, diaryId 컬럼에 인덱스 누락

카테고리별/다이어리별 추천 목록 조회 시 필터 조건으로 쓰일 컬럼들인데 인덱스가 없습니다. @Index 추가를 권장합니다.

As per path instructions, "필요한 인덱스/유니크 제약이 누락되지 않았는지" 확인이 필요합니다.

♻️ 제안
-import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
+import { Column, Entity, Index, PrimaryGeneratedColumn } from 'typeorm';
 import { BaseModel } from '../../global/base-model';

 `@Entity`('recommend')
 export class RecommendEntity extends BaseModel {
   `@PrimaryGeneratedColumn`({
     name: 'recommend_id',
     type: 'int',
   })
   recommendId: number;

+  `@Index`()
   `@Column`({
     name: 'category_id',
     type: 'int',
     nullable: false,
     comment: '카테고리 아이디',
   })
   categoryId: number;

+  `@Index`()
   `@Column`({
     name: 'diary_id',
     type: 'int',
     nullable: false,
     comment: '일기 아이디',
   })
   diaryId: number;
🤖 Prompt for 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.

In `@src/diaries/entities/recommend.entity.ts` around lines 12 - 26, The recommend
entity is missing indexes on the filter columns used for category- and
diary-based lookups. Add `@Index` decorators for categoryId and diaryId in
RecommendEntity so queries using these fields can use the database index
efficiently; keep the column definitions as-is and place the indexes alongside
the existing `@Column` fields.

Source: Path instructions

src/diaries/entities/diary.entity.ts (1)

13-18: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

userId 컬럼에 인덱스 누락

사용자별 다이어리 목록 조회 시 userId로 필터링하는 쿼리가 빈번할 것으로 예상되는데 인덱스가 없습니다. 조회 성능을 위해 @Index 추가를 권장합니다.

As per path instructions, "필요한 인덱스/유니크 제약이 누락되지 않았는지" 확인이 필요합니다.

♻️ 제안
-import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
+import { Column, Entity, Index, PrimaryGeneratedColumn } from 'typeorm';
 import { SoftDeleteModel } from '../../global/base-model';
 import { DiaryType } from '../enums/diary-type.enum';

 `@Entity`('diary')
 export class DiaryEntity extends SoftDeleteModel {
   `@PrimaryGeneratedColumn`({
     name: 'diary_id',
     type: 'int',
   })
   diaryId: number;

+  `@Index`()
   `@Column`({
     name: 'user_id',
     type: 'int',
     comment: '사용자 아이디',
   })
   userId: number;
🤖 Prompt for 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.

In `@src/diaries/entities/diary.entity.ts` around lines 13 - 18, `Diary` 엔티티의
`userId` 컬럼에 인덱스가 없어 사용자별 조회 성능이 떨어질 수 있습니다. `Diary` 클래스와 `userId` 프로퍼티를 기준으로
`@Index`를 추가해 `user_id` 필터링 쿼리가 인덱스를 타도록 수정하고, 필요하다면 엔티티 레벨 인덱스 정의로 `userId` 조회
패턴에 맞게 반영하세요.

Source: Path instructions

🤖 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.

Nitpick comments:
In `@src/diaries/entities/diary-image.entity.ts`:
- Around line 12-18: The diary image entity is missing an index on the `diaryId`
field, which is likely used for filtering image lists by diary. Add an `@Index`
on the `DiaryImage` entity for the `diaryId` property, keeping the existing
`@Column` mapping intact, so lookups via `diaryId` are optimized.

In `@src/diaries/entities/diary.entity.ts`:
- Around line 13-18: `Diary` 엔티티의 `userId` 컬럼에 인덱스가 없어 사용자별 조회 성능이 떨어질 수 있습니다.
`Diary` 클래스와 `userId` 프로퍼티를 기준으로 `@Index`를 추가해 `user_id` 필터링 쿼리가 인덱스를 타도록 수정하고,
필요하다면 엔티티 레벨 인덱스 정의로 `userId` 조회 패턴에 맞게 반영하세요.

In `@src/diaries/entities/recommend.entity.ts`:
- Around line 12-26: The recommend entity is missing indexes on the filter
columns used for category- and diary-based lookups. Add `@Index` decorators for
categoryId and diaryId in RecommendEntity so queries using these fields can use
the database index efficiently; keep the column definitions as-is and place the
indexes alongside the existing `@Column` fields.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 534c9ca1-cfc8-4f40-807c-1218ae60d1e0

📥 Commits

Reviewing files that changed from the base of the PR and between becaba6 and f522f21.

📒 Files selected for processing (6)
  • src/app.module.ts
  • src/diaries/diary.module.ts
  • src/diaries/entities/diary-image.entity.ts
  • src/diaries/entities/diary.entity.ts
  • src/diaries/entities/recommend.entity.ts
  • src/diaries/enums/diary-type.enum.ts

@yangwooyoung123 yangwooyoung123 changed the title diary entities 추가 [Feat/#]diary entities 추가 Jul 9, 2026
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.

1 participant