Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.example.solidconnection.siteuser.domain;

import com.example.solidconnection.common.BaseEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Entity
@AllArgsConstructor
@Table(uniqueConstraints = {
@UniqueConstraint(
name = "uk_user_block_blocker_id_blocked_id",
columnNames = {"blocker_id", "blocked_id"}
)
})
public class UserBlock extends BaseEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(name = "blocker_id", nullable = false)
private long blockerId;

@Column(name = "blocked_id", nullable = false)
private long blockedId;
}
12 changes: 12 additions & 0 deletions src/main/resources/db/migration/V32__add_user_block_table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CREATE TABLE user_block
(
id BIGINT NOT NULL AUTO_INCREMENT,
blocker_id BIGINT NOT NULL,
blocked_id BIGINT NOT NULL,
created_at DATETIME(6) NOT NULL,
updated_at DATETIME(6) NOT NULL,
PRIMARY KEY (id),
CONSTRAINT uk_user_block_blocker_id_blocked_id UNIQUE (blocker_id, blocked_id),
CONSTRAINT fk_user_block_blocker_id FOREIGN KEY (blocker_id) REFERENCES site_user (id),
CONSTRAINT fk_user_block_blocked_id FOREIGN KEY (blocked_id) REFERENCES site_user (id)
);
Loading