Skip to content

Commit

Permalink
refactor: studentCode unique 제약조건 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
xxeol2 committed Sep 27, 2023
1 parent e7460e8 commit 2087790
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
12 changes: 2 additions & 10 deletions backend/src/main/java/com/festago/student/domain/StudentCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,14 @@
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
import java.time.LocalDateTime;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.util.StringUtils;

@Entity
@Table(
uniqueConstraints = {
@UniqueConstraint(
name = "unique_username__school",
columnNames = {"username", "school_id"}
)
}
)
public class StudentCode extends BaseTimeEntity {

private static final int MIN_REQUEST_TERM_SECONDS = 30;
Expand All @@ -45,6 +36,7 @@ public class StudentCode extends BaseTimeEntity {
private School school;

@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(unique = true)
private Member member;

private String username;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
alter table student_code
add constraint unique_username__school unique (username, school_id);
create index temp_member_index
on student_code (member_id);

drop index fk_student_code__member on student_code;

create unique index fk_student_code__member
on student_code (member_id);

drop index temp_member_index on student_code;

alter table student_code
add column issued_at datetime(6);

0 comments on commit 2087790

Please sign in to comment.