[Feat/#]diary entities 추가#18
Conversation
WalkthroughDiariesModule을 신규 생성하고 app.module.ts에 등록했다. DiaryEntity, DiaryImageEntity, RecommendEntity TypeORM 엔티티와 DiaryType enum을 새로 추가하여 다이어리 관련 테이블 스키마를 정의했다. ChangesDiaries 모듈 및 엔티티
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 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
📒 Files selected for processing (6)
src/app.module.tssrc/diaries/diary.module.tssrc/diaries/entities/diary-image.entity.tssrc/diaries/entities/diary.entity.tssrc/diaries/entities/recommend.entity.tssrc/diaries/enums/diary-type.enum.ts
📌 PR 제목
[Feat/#14] 다이어리 엔티티 추가
📌 관련 이슈번호
(Closes 키워드가 있어야 PR이 머지되었을 때 이슈가 자동으로 닫힌다)
📌 PR 유형
어떤 변경 사항이 있나요?
📌 PR 요약
Diary 도메인의 엔티티 및 모듈을 추가했습니다.
📌 작업 세부 내용
📸 스크린샷 (선택)
🔗 참고 자료