Blog 모델 4개 + 마이그레이션 구현 (TDD)
ID: bbc577e1-7dee-45ff-813a-359fb00976d2
Blog::Category, Blog::Post, Blog::Comment, Blog::Like 4개 모델과 마이그레이션을 TDD로 구현합니다.
## 스키마
- blog_categories: id(uuid), name(string), slug(string, unique index), description(text), timestamps
- blog_posts: id(uuid), author_id(uuid FK→users), category_id(uuid FK→blog_categories), title(string), slug(string, unique index), content(text/HTML), excerpt(text), description(text), keywords(string), status(integer, enum: draft/published/archived), view_count(integer, default: 0), published_at(datetime), timestamps, featured_image(ActiveStorage)
- blog_comments: id(uuid), post_id(uuid FK→blog_posts), author_id(uuid FK→users), parent_id(uuid, self-ref nullable), content(text), timestamps
- blog_likes: id(uuid), post_id(uuid FK→blog_posts), user_id(uuid FK→users), timestamps, unique index(post_id, user_id)
## 완료 기준
- 마이그레이션 성공 + 롤백 + 재마이그레이션
- 모델 유효성 검사 테스트 통과
- slug 자동 생성 (parameterize), enum 동작, 연관관계 동작
- featured_image ActiveStorage 첨부
- blog_posts에 author_id, category_id 인덱스
첨부 이미지
이미지 추가 (Ctrl+V로 붙여넣기 또는 클릭)
JPEG, PNG, GIF, WebP / 최대 10MB
활동 로그
-
Ddeveloper-1 상태 변경: 리뷰 → 완료
2026년 03월 11일 12:48:00
-
Ddeveloper-1 Blog 모델 4개 구현 완료 (45/45 테스트 통과)
2026년 03월 11일 12:40:42
상세 보기
## 생성된 파일
### 마이그레이션 (4)
- `db/migrate/20260311100000_create_blog_categories.rb`
- `db/migrate/20260311100001_create_blog_posts.rb`
- `db/migrate/20260311100002_create_blog_comments.rb`
- `db/migrate/20260311100003_create_blog_likes.rb`
- `db/migrate/20260311123734_create_active_storage_tables.active_storage.rb`### 모델 (5)
- `app/models/blog.rb` — table_name_prefix "blog_"
- `app/models/blog/category.rb`
- `app/models/blog/post.rb`
- `app/models/blog/comment.rb`
- `app/models/blog/like.rb`### 테스트 (4파일, 45 tests)
- `test/models/blog/category_test.rb` (9)
- `test/models/blog/post_test.rb` (21)
- `test/models/blog/comment_test.rb` (9)
- `test/models/blog/like_test.rb` (6)### Fixtures (4)
- `test/fixtures/blog/categories.yml`
- `test/fixtures/blog/posts.yml`
- `test/fixtures/blog/comments.yml`
- `test/fixtures/blog/likes.yml`### 수정된 파일
- `app/models/user.rb` — has_many :blog_posts, :blog_comments, :blog_likes 추가## 검증
- 45/45 테스트 통과
- 마이그레이션 → 롤백 → 재마이그레이션 성공
- Development DB 무사 (users: 9066, sessions: 8509) -
Ddeveloper-1 상태 변경: 할 일 → 리뷰
2026년 03월 11일 12:40:35