diff --git a/backend/src/main/java/wooteco/prolog/member/domain/Department.java b/backend/src/main/java/wooteco/prolog/member/domain/Department.java index 0e802847e..caa489391 100644 --- a/backend/src/main/java/wooteco/prolog/member/domain/Department.java +++ b/backend/src/main/java/wooteco/prolog/member/domain/Department.java @@ -2,10 +2,8 @@ import static wooteco.prolog.common.exception.BadRequestCode.CANT_FIND_GROUP_TYPE; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; +import javax.persistence.*; + import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; @@ -20,8 +18,10 @@ public class Department { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; + @Enumerated(value = EnumType.STRING) private Part part; + @Enumerated(value = EnumType.STRING) private Term term; public Department(Long id, String part, String term) { diff --git a/backend/src/main/resources/db/migration/prod/V9__alter_table_group_and_member.sql b/backend/src/main/resources/db/migration/prod/V9__alter_table_group_and_member.sql new file mode 100644 index 000000000..6766b3a8e --- /dev/null +++ b/backend/src/main/resources/db/migration/prod/V9__alter_table_group_and_member.sql @@ -0,0 +1,30 @@ +CREATE TABLE IF NOT EXISTS department +( + id bigint auto_increment primary key, + part varchar(50) not null, + term varchar(50) not null +) ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4; + +create table if not exists department_member +( + id bigint auto_increment primary key, + member_id bigint not null, + department_id bigint not null, + constraint FK_DEPARTMENT_MEMBER_ON_MEMBERㅇ + foreign key (member_id) references prolog.member (id), + constraint FK_DEPARTMENT_MEMBER_ON_DEPARTMENT + foreign key (department_id) references prolog.department (id) +) ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4; + +insert into department(id, part, term) values (1, '백엔드', '3기'); +insert into department(id, part, term) values (2, '프론트엔드', '3기'); +insert into department(id, part, term) values (3, '백엔드', '4기'); +insert into department(id, part, term) values (4, '프론트엔드', '4기'); +insert into department(id, part, term) values (5, '백엔드', '5기'); +insert into department(id, part, term) values (6, '프론트엔드', '5기'); +insert into department(id, part, term) values (7, '안드로이드', '5기'); + +insert into department_member (id, member_id, department_id) + (select id, member_id, group_id from group_member);