-
Notifications
You must be signed in to change notification settings - Fork 8
feat: 소식지 좋아요 엔티티 추가 #359
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
feat: 소식지 좋아요 엔티티 추가 #359
Conversation
Walkthrough
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/main/resources/db/migration/V21__create_liked_news_table.sql (1)
1-9: 1)created_at타임스탬프 &ON DELETE CASCADE옵션이 누락되었습니다
- 좋아요 시점을 기록할 컬럼이 없으면, 시간 별 통계나 “최근 내가 누른 좋아요” 같은 기능 구현이 곤란해집니다.
- 두 FK 모두 부모가 삭제될 때 자식 레코드가 고아로 남습니다.
ON DELETE CASCADE로 정리 루틴을 DB에 맡기면 코드가 간결해집니다.site_user_id BIGINT NOT NULL, + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, ... - CONSTRAINT fk_liked_news_news_id FOREIGN KEY (news_id) REFERENCES news(id), - CONSTRAINT fk_liked_news_site_user_id FOREIGN KEY (site_user_id) REFERENCES site_user(id) + CONSTRAINT fk_liked_news_news_id + FOREIGN KEY (news_id) REFERENCES news(id) ON DELETE CASCADE, + CONSTRAINT fk_liked_news_site_user_id + FOREIGN KEY (site_user_id) REFERENCES site_user(id) ON DELETE CASCADE필요하다면 Flyway 마이그레이션 스크립트 버전 업과 롤백 스크립트까지 같이 드릴 수 있어요!
src/main/java/com/example/solidconnection/news/domain/LikedNews.java (1)
17-18: 4)@AllArgsConstructor가 id까지 노출합니다
id는 JPA에서 자동 생성되므로 외부 생성자에서 받지 않는 편이 안전합니다.-@AllArgsConstructor +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@Builder그리고 정적 팩토리
of(News, SiteUser)형태를 두면 테스트 작성도 편해집니다.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/main/java/com/example/solidconnection/news/domain/LikedNews.java(1 hunks)src/main/resources/db/migration/V21__create_liked_news_table.sql(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build
🔇 Additional comments (1)
src/main/java/com/example/solidconnection/news/domain/LikedNews.java (1)
19-24: 2) 유니크 제약 설정 👍
JPA → DB → 엔티티 모두 일관성 있게 매핑되었습니다. 중복 좋아요 방지가 확실히 되겠네요!
whqtker
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다!
application-db.yml 의 dev 프로파일의 jpa, flyway 설정 복사하셔서 local 프로파일에 붙여넣으신 후, user, password 옵션 지우고 실행하시면 됩니다. (로컬 DB에서 테이블 다 drop하고 해야 합니다!)
2025-06-30T23:19:52.379+09:00 INFO 19204 --- [ main] o.f.core.internal.command.DbMigrate : Migrating schema `solid_connection` to version "1 - init"
2025-06-30T23:19:55.533+09:00 INFO 19204 --- [ main] o.f.core.internal.command.DbMigrate : Migrating schema `solid_connection` to version "2 - add gpa score and language test score"
2025-06-30T23:19:57.340+09:00 INFO 19204 --- [ main] o.f.core.internal.command.DbMigrate : Migrating schema `solid_connection` to version "3 - add auth type column and unique key"
2025-06-30T23:19:57.643+09:00 INFO 19204 --- [ main] o.f.core.internal.command.DbMigrate : Migrating schema `solid_connection` to version "4 - remove issue date columns"
2025-06-30T23:19:57.858+09:00 INFO 19204 --- [ main] o.f.core.internal.command.DbMigrate : Migrating schema `solid_connection` to version "5 - add password column"
2025-06-30T23:19:57.995+09:00 INFO 19204 --- [ main] o.f.core.internal.command.DbMigrate : Migrating schema `solid_connection` to version "6 - add admin to role enum"
2025-06-30T23:19:58.072+09:00 INFO 19204 --- [ main] o.f.core.internal.command.DbMigrate : Migrating schema `solid_connection` to version "7 - expand details column length"
2025-06-30T23:19:58.140+09:00 INFO 19204 --- [ main] o.f.core.internal.command.DbMigrate : Migrating schema `solid_connection` to version "8 - add two semester to semeter avaliable enum"
2025-06-30T23:19:58.286+09:00 INFO 19204 --- [ main] o.f.core.internal.command.DbMigrate : Migrating schema `solid_connection` to version "9 - add etc to language test type enum"
2025-06-30T23:19:58.342+09:00 INFO 19204 --- [ main] o.f.core.internal.command.DbMigrate : Migrating schema `solid_connection` to version "10 - change update count default value"
2025-06-30T23:19:58.387+09:00 INFO 19204 --- [ main] o.f.core.internal.command.DbMigrate : Migrating schema `solid_connection` to version "11 - remove siteuser birth and gender"
2025-06-30T23:19:58.530+09:00 INFO 19204 --- [ main] o.f.core.internal.command.DbMigrate : Migrating schema `solid_connection` to version "12 - create news"
2025-06-30T23:19:58.607+09:00 INFO 19204 --- [ main] o.f.core.internal.command.DbMigrate : Migrating schema `solid_connection` to version "13 - add application index and delete manny to one mapping"
2025-06-30T23:19:58.803+09:00 INFO 19204 --- [ main] o.f.core.internal.command.DbMigrate : Migrating schema `solid_connection` to version "14 - set unique constraint to nickname"
2025-06-30T23:19:58.890+09:00 INFO 19204 --- [ main] o.f.core.internal.command.DbMigrate : Migrating schema `solid_connection` to version "15 - add unique constraint to liked university"
2025-06-30T23:19:58.958+09:00 INFO 19204 --- [ main] o.f.core.internal.command.DbMigrate : Migrating schema `solid_connection` to version "16 - add unique constraint to intersted"
2025-06-30T23:19:59.050+09:00 INFO 19204 --- [ main] o.f.core.internal.command.DbMigrate : Migrating schema `solid_connection` to version "21 - create liked news table"
2025-06-30T23:19:59.146+09:00 INFO 19204 --- [ main] o.f.core.internal.command.DbMigrate : Successfully applied 17 migrations to schema `solid_connection`, now at version v21 (execution time 00:06.796s)잘 생성됩니다 !
아하 감사합니다 ㅎㅎ |
nayonsoso
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name을 명시해주지 않으니까 JPA가 이를 인식하지 못해
이 부분에 대해 더 자세히 설명해주실 수 있나요? 😯
|
name 명시를 안해주니까 아래와 같은 에러가 발생하더라구요! 혹시 모르니 지우고 다시 한 번 테스트 해보겠습니다!
다시 지우고 해봤는데 같은 에러가 발생합니다! |
lsy1307
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수고하셨어용!
관련 이슈
작업 내용
소식지 좋아요 엔티티를 추가하였습니다!
특이 사항
name을 명시해주지 않으니까
JPA가 이를 인식하지 못해 별도로 추가해주었습니다!
리뷰 요구사항 (선택)
혹시 로컬에서 이거 flyway validate 확인하는 법 알려주실 수 있나요?
우선 flyway 스크립트로 테이블 생성해보았을 땐 잘 작동하였습니다!