Skip to content

Commit

Permalink
chore: 제약 조건 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
seongjae6751 committed Sep 19, 2024
1 parent cea1bde commit 73c59c0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@Entity
@Table(name = "article_search_keyword_ip_map", indexes = {
@Index(name = "idx_ip_address", columnList = "ipAddress")
@Index(name = "idx_ip_address", columnList = "ipAddress")}, uniqueConstraints = {
@UniqueConstraint(name = "ux_keyword_ip", columnNames = {"keyword_id", "ipAddress"})
})
@NoArgsConstructor(access = PROTECTED)
public class ArticleSearchKeywordIpMap extends BaseEntity {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ALTER TABLE `article_search_keywords`
MODIFY COLUMN `keyword` VARCHAR(255) NOT NULL UNIQUE;

ALTER TABLE article_search_keyword_ip_map
ADD CONSTRAINT unique_keyword_ip UNIQUE (keyword_id, ip_address),
ADD CONSTRAINT fk_keyword_id
FOREIGN KEY (keyword_id)
REFERENCES article_search_keywords (id)
ON DELETE CASCADE;

0 comments on commit 73c59c0

Please sign in to comment.