feat: 브랜드 및 채널 브랜드 엔티티와 테이블을 추가 -> Dev#107
Hidden character warning
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
Walkthrough브랜드 도메인 모델을 위한 세 개의 JPA 엔티티( ChangesBrand Domain Entities & Schema
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
src/main/resources/db/migration/V20260505205249__create_index_brand_alias_column_brand_id.sql (1)
1-1: 💤 Low value
brand_id단독 인덱스가 복합 유니크 제약의 인덱스와 중복됩니다.PostgreSQL은 UNIQUE 제약을 정의할 때 해당 컬럼에 대한 유니크 인덱스를 자동으로 생성하며, 유니크 컬럼에 별도로 인덱스를 생성할 필요가 없습니다 — 그렇게 하면 자동 생성된 인덱스가 중복될 뿐입니다.
uk_brand_alias UNIQUE (brand_id, alias)가 이미brand_id를 선두 컬럼으로 하는 B-tree 인덱스를 생성하므로,brand_id만 필터링하는 쿼리도 해당 복합 인덱스로 처리할 수 있습니다. 이 마이그레이션은 불필요한 쓰기 오버헤드와 스토리지 사용을 추가합니다.🤖 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/main/resources/db/migration/V20260505205249__create_index_brand_alias_column_brand_id.sql` at line 1, 이 마이그레이션은 복합 유니크 제약 uk_brand_alias (UNIQUE (brand_id, alias))가 이미 brand_id를 선두 컬럼으로 하는 인덱스를 생성하므로 별도 인덱스 idx_brand_alias_brand_id를 만들지 말고 해당 CREATE INDEX 문을 제거하거나 마이그레이션에서 조건부로 건너뛰도록 수정하세요; 구체적으로 V20260505205249__create_index_brand_alias_column_brand_id.sql에서 "CREATE INDEX IF NOT EXISTS idx_brand_alias_brand_id ON brand_alias (brand_id);" 라인을 삭제하거나 유니크 제약 존재 여부를 확인한 뒤에만 인덱스를 생성하도록 변경하세요.
🤖 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.
Inline comments:
In `@src/main/java/com/example/inflace/domain/brand/domain/Brand.java`:
- Around line 14-21: The Brand entity lacks a way to be created from outside its
package; add a protected no-args constructor and a public static factory to
construct instances with name. Specifically, annotate Brand with
`@NoArgsConstructor`(access = AccessLevel.PROTECTED) (or add a protected no-arg
constructor), add a private constructor that accepts String name (or use
`@AllArgsConstructor`(access = AccessLevel.PRIVATE)), and add a public static
Brand of(String name) factory that returns a new Brand with the name field set;
reference the Brand class, name field, and the of() factory in your changes.
In `@src/main/java/com/example/inflace/domain/brand/domain/BrandAlias.java`:
- Around line 6-22: Add a protected no-args constructor and a controlled
creation API for BrandAlias: annotate the BrandAlias class with
`@NoArgsConstructor`(access = AccessLevel.PROTECTED) (to match Brand and
ChannelBrand) and provide a public constructor or static factory method (e.g.,
BrandAlias.of(Brand brand, String alias) or a public BrandAlias(Brand brand,
String alias)) that sets the brand and alias fields on creation so service code
can instantiate valid instances; reference the BrandAlias class and its brand
and alias fields when making the changes.
In
`@src/main/resources/db/migration/V20260505205437__create_table_channel_brand.sql`:
- Line 10: The migration SQL is truncated at the UNIQUE constraint; fix the
CONSTRAINT uk_channel_brand line to reference the full column name and close the
DDL: change the fragment to CONSTRAINT uk_channel_brand UNIQUE (channel_id,
brand_id), then ensure the CREATE TABLE statement has its closing parenthesis
and a terminating semicolon so the table definition is complete and Flyway can
parse it.
---
Nitpick comments:
In
`@src/main/resources/db/migration/V20260505205249__create_index_brand_alias_column_brand_id.sql`:
- Line 1: 이 마이그레이션은 복합 유니크 제약 uk_brand_alias (UNIQUE (brand_id, alias))가 이미
brand_id를 선두 컬럼으로 하는 인덱스를 생성하므로 별도 인덱스 idx_brand_alias_brand_id를 만들지 말고 해당
CREATE INDEX 문을 제거하거나 마이그레이션에서 조건부로 건너뛰도록 수정하세요; 구체적으로
V20260505205249__create_index_brand_alias_column_brand_id.sql에서 "CREATE INDEX IF
NOT EXISTS idx_brand_alias_brand_id ON brand_alias (brand_id);" 라인을 삭제하거나 유니크 제약
존재 여부를 확인한 뒤에만 인덱스를 생성하도록 변경하세요.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2bcdf1ce-512e-419c-a1b0-75d1f6a7b381
📒 Files selected for processing (8)
src/main/java/com/example/inflace/domain/brand/domain/Brand.javasrc/main/java/com/example/inflace/domain/brand/domain/BrandAlias.javasrc/main/java/com/example/inflace/domain/channel/domain/ChannelBrand.javasrc/main/resources/db/migration/V20260505204433__create_table_brand.sqlsrc/main/resources/db/migration/V20260505204848__create_table_brand_alias.sqlsrc/main/resources/db/migration/V20260505205249__create_index_brand_alias_column_brand_id.sqlsrc/main/resources/db/migration/V20260505205347__create_index_brand_alias_column_alias.sqlsrc/main/resources/db/migration/V20260505205437__create_table_channel_brand.sql
| public class Brand { | ||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long id; | ||
|
|
||
| @Column(name = "name", nullable = false) | ||
| private String name; | ||
| } |
There was a problem hiding this comment.
Brand 인스턴스를 생성할 방법이 없습니다.
@NoArgsConstructor(access = AccessLevel.PROTECTED)와 setter가 없어, 서비스 레이어(다른 패키지)에서 name이 설정된 Brand를 생성할 수 없습니다. ChannelBrand는 이미 of() 정적 팩터리 메서드 패턴을 사용하고 있습니다.
🏭 정적 팩터리 메서드 추가 제안
public class Brand {
`@Id`
`@GeneratedValue`(strategy = GenerationType.IDENTITY)
private Long id;
`@Column`(name = "name", nullable = false)
private String name;
+
+ public static Brand of(String name) {
+ Brand brand = new Brand();
+ brand.name = name;
+ return brand;
+ }
}📝 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.
| public class Brand { | |
| @Id | |
| @GeneratedValue(strategy = GenerationType.IDENTITY) | |
| private Long id; | |
| @Column(name = "name", nullable = false) | |
| private String name; | |
| } | |
| public class Brand { | |
| `@Id` | |
| `@GeneratedValue`(strategy = GenerationType.IDENTITY) | |
| private Long id; | |
| `@Column`(name = "name", nullable = false) | |
| private String name; | |
| public static Brand of(String name) { | |
| Brand brand = new Brand(); | |
| brand.name = name; | |
| return brand; | |
| } | |
| } |
🤖 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/main/java/com/example/inflace/domain/brand/domain/Brand.java` around
lines 14 - 21, The Brand entity lacks a way to be created from outside its
package; add a protected no-args constructor and a public static factory to
construct instances with name. Specifically, annotate Brand with
`@NoArgsConstructor`(access = AccessLevel.PROTECTED) (or add a protected no-arg
constructor), add a private constructor that accepts String name (or use
`@AllArgsConstructor`(access = AccessLevel.PRIVATE)), and add a public static
Brand of(String name) factory that returns a new Brand with the name field set;
reference the Brand class, name field, and the of() factory in your changes.
| @Entity | ||
| @Table(name = "brand_alias", uniqueConstraints = { | ||
| @UniqueConstraint(columnNames = {"brand_id", "alias"}) | ||
| }) | ||
| @Getter | ||
| public class BrandAlias { | ||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| private Long id; | ||
|
|
||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "brand_id", nullable = false) | ||
| private Brand brand; | ||
|
|
||
| @Column(name = "alias", nullable = false) | ||
| private String alias; | ||
| } |
There was a problem hiding this comment.
@NoArgsConstructor 접근 제한 누락 및 인스턴스 생성 방법 부재
두 가지 문제가 있습니다:
@NoArgsConstructor가 없어 Java의 기본public생성자가 노출됩니다.Brand,ChannelBrand는 모두@NoArgsConstructor(access = AccessLevel.PROTECTED)를 사용합니다.Brand와 동일하게, 서비스 레이어에서brand와alias가 설정된 인스턴스를 생성할 방법이 없습니다.
🏭 수정 제안
import jakarta.persistence.*;
+import lombok.AccessLevel;
import lombok.Getter;
+import lombok.NoArgsConstructor;
`@Entity`
`@Table`(name = "brand_alias", uniqueConstraints = {
`@UniqueConstraint`(columnNames = {"brand_id", "alias"})
})
`@Getter`
+@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class BrandAlias {
`@Id`
`@GeneratedValue`(strategy = GenerationType.IDENTITY)
private Long id;
`@ManyToOne`(fetch = FetchType.LAZY)
`@JoinColumn`(name = "brand_id", nullable = false)
private Brand brand;
`@Column`(name = "alias", nullable = false)
private String alias;
+
+ public static BrandAlias of(Brand brand, String alias) {
+ BrandAlias brandAlias = new BrandAlias();
+ brandAlias.brand = brand;
+ brandAlias.alias = alias;
+ return brandAlias;
+ }
}🤖 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/main/java/com/example/inflace/domain/brand/domain/BrandAlias.java` around
lines 6 - 22, Add a protected no-args constructor and a controlled creation API
for BrandAlias: annotate the BrandAlias class with `@NoArgsConstructor`(access =
AccessLevel.PROTECTED) (to match Brand and ChannelBrand) and provide a public
constructor or static factory method (e.g., BrandAlias.of(Brand brand, String
alias) or a public BrandAlias(Brand brand, String alias)) that sets the brand
and alias fields on creation so service code can instantiate valid instances;
reference the BrandAlias class and its brand and alias fields when making the
changes.
Issue
comment
Summary by CodeRabbit
새로운 기능
데이터베이스