From 2f64b33e647b596559b74c977ca924bf5e5a5ad0 Mon Sep 17 00:00:00 2001 From: coli Date: Thu, 10 Jul 2025 09:41:20 +0900 Subject: [PATCH 1/7] =?UTF-8?q?feat:=20PollEntity=20=EC=84=B8=ED=8C=85=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../debatetimer/domain/poll/PollStatus.java | 8 ++++ .../debatetimer/entity/poll/PollEntity.java | 37 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 src/main/java/com/debatetimer/domain/poll/PollStatus.java create mode 100644 src/main/java/com/debatetimer/entity/poll/PollEntity.java diff --git a/src/main/java/com/debatetimer/domain/poll/PollStatus.java b/src/main/java/com/debatetimer/domain/poll/PollStatus.java new file mode 100644 index 00000000..f2d0ebad --- /dev/null +++ b/src/main/java/com/debatetimer/domain/poll/PollStatus.java @@ -0,0 +1,8 @@ +package com.debatetimer.domain.poll; + +public enum PollStatus { + + PROGRESS, + DONE, + ; +} diff --git a/src/main/java/com/debatetimer/entity/poll/PollEntity.java b/src/main/java/com/debatetimer/entity/poll/PollEntity.java new file mode 100644 index 00000000..b97bb58c --- /dev/null +++ b/src/main/java/com/debatetimer/entity/poll/PollEntity.java @@ -0,0 +1,37 @@ +package com.debatetimer.entity.poll; + +import com.debatetimer.domain.poll.PollStatus; +import com.debatetimer.entity.customize.BaseTimeEntity; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; + +@Entity +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class PollEntity extends BaseTimeEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + private long tableId; + + @NotNull + @Enumerated(EnumType.STRING) + private PollStatus status; + + @NotBlank + private String prosTeamName; + + @NotBlank + private String consTeamName; + + private String agenda; +} From 989eb32289f849657470018a8f7e962b16d93611 Mon Sep 17 00:00:00 2001 From: coli Date: Thu, 10 Jul 2025 09:47:50 +0900 Subject: [PATCH 2/7] =?UTF-8?q?feat:=20VoteEntity=20=EC=84=B8=ED=8C=85=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/debatetimer/domain/poll/VoteTeam.java | 4 ++ .../debatetimer/entity/poll/PollEntity.java | 2 + .../debatetimer/entity/poll/VoteEntity.java | 42 +++++++++++++++++++ .../V10__create_poll_and_vote_table.sql | 21 ++++++++++ 4 files changed, 69 insertions(+) create mode 100644 src/main/java/com/debatetimer/domain/poll/VoteTeam.java create mode 100644 src/main/java/com/debatetimer/entity/poll/VoteEntity.java create mode 100644 src/main/resources/db/migration/V10__create_poll_and_vote_table.sql diff --git a/src/main/java/com/debatetimer/domain/poll/VoteTeam.java b/src/main/java/com/debatetimer/domain/poll/VoteTeam.java new file mode 100644 index 00000000..e5dcface --- /dev/null +++ b/src/main/java/com/debatetimer/domain/poll/VoteTeam.java @@ -0,0 +1,4 @@ +package com.debatetimer.domain.poll; + +public enum VoteTeam { +} diff --git a/src/main/java/com/debatetimer/entity/poll/PollEntity.java b/src/main/java/com/debatetimer/entity/poll/PollEntity.java index b97bb58c..d4700a3d 100644 --- a/src/main/java/com/debatetimer/entity/poll/PollEntity.java +++ b/src/main/java/com/debatetimer/entity/poll/PollEntity.java @@ -8,12 +8,14 @@ import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; +import jakarta.persistence.Table; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import lombok.AccessLevel; import lombok.NoArgsConstructor; @Entity +@Table(name = "poll") @NoArgsConstructor(access = AccessLevel.PROTECTED) public class PollEntity extends BaseTimeEntity { diff --git a/src/main/java/com/debatetimer/entity/poll/VoteEntity.java b/src/main/java/com/debatetimer/entity/poll/VoteEntity.java new file mode 100644 index 00000000..9b01e7f4 --- /dev/null +++ b/src/main/java/com/debatetimer/entity/poll/VoteEntity.java @@ -0,0 +1,42 @@ +package com.debatetimer.entity.poll; + +import com.debatetimer.domain.poll.VoteTeam; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.FetchType; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; + +@Entity +@Table(name = "vote") +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class VoteEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @NotNull + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "poll_id") + private PollEntity poll; + + @NotNull + @Enumerated(EnumType.STRING) + private VoteTeam team; + + @NotBlank + private String name; + + @NotBlank + private String participantCode; +} diff --git a/src/main/resources/db/migration/V10__create_poll_and_vote_table.sql b/src/main/resources/db/migration/V10__create_poll_and_vote_table.sql new file mode 100644 index 00000000..4da5dbf6 --- /dev/null +++ b/src/main/resources/db/migration/V10__create_poll_and_vote_table.sql @@ -0,0 +1,21 @@ +CREATE TABLE poll +( + id BIGINT AUTO_INCREMENT PRIMARY KEY, + table_id BIGINT NOT NULL, + status VARCHAR(255) NOT NULL, -- ENUM형은 VARCHAR로 매핑됨 + pros_team_name VARCHAR(255) NOT NULL, + cons_team_name VARCHAR(255) NOT NULL, + agenda TEXT, + created_at DATETIME(6) NOT NULL, + updated_at DATETIME(6) NOT NULL +); + +CREATE TABLE vote +( + id BIGINT AUTO_INCREMENT PRIMARY KEY, + poll_id BIGINT NOT NULL, + team VARCHAR(255) NOT NULL, -- ENUM형은 VARCHAR로 매핑됨 + name VARCHAR(255) NOT NULL, + participant_code VARCHAR(255) NOT NULL, + CONSTRAINT fk_vote_poll FOREIGN KEY (poll_id) REFERENCES poll_entity (id) ON DELETE CASCADE +); From 805f0be7ac528c8930ffee1808bc7aa09ff4a161 Mon Sep 17 00:00:00 2001 From: coli Date: Thu, 10 Jul 2025 09:49:36 +0900 Subject: [PATCH 3/7] =?UTF-8?q?chore:=20flyway=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=9D=B4=EB=A6=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...nd_vote_table.sql => V9__create_poll_and_vote_table.sql} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename src/main/resources/db/migration/{V10__create_poll_and_vote_table.sql => V9__create_poll_and_vote_table.sql} (75%) diff --git a/src/main/resources/db/migration/V10__create_poll_and_vote_table.sql b/src/main/resources/db/migration/V9__create_poll_and_vote_table.sql similarity index 75% rename from src/main/resources/db/migration/V10__create_poll_and_vote_table.sql rename to src/main/resources/db/migration/V9__create_poll_and_vote_table.sql index 4da5dbf6..1914c06e 100644 --- a/src/main/resources/db/migration/V10__create_poll_and_vote_table.sql +++ b/src/main/resources/db/migration/V9__create_poll_and_vote_table.sql @@ -2,7 +2,7 @@ CREATE TABLE poll ( id BIGINT AUTO_INCREMENT PRIMARY KEY, table_id BIGINT NOT NULL, - status VARCHAR(255) NOT NULL, -- ENUM형은 VARCHAR로 매핑됨 + status VARCHAR(255) NOT NULL, pros_team_name VARCHAR(255) NOT NULL, cons_team_name VARCHAR(255) NOT NULL, agenda TEXT, @@ -14,8 +14,8 @@ CREATE TABLE vote ( id BIGINT AUTO_INCREMENT PRIMARY KEY, poll_id BIGINT NOT NULL, - team VARCHAR(255) NOT NULL, -- ENUM형은 VARCHAR로 매핑됨 + team VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, participant_code VARCHAR(255) NOT NULL, - CONSTRAINT fk_vote_poll FOREIGN KEY (poll_id) REFERENCES poll_entity (id) ON DELETE CASCADE + CONSTRAINT fk_vote_poll FOREIGN KEY (poll_id) REFERENCES poll (id) ON DELETE CASCADE ); From 4842abdab6d6ab11c7661b46ad99969decfc8126 Mon Sep 17 00:00:00 2001 From: coli Date: Thu, 10 Jul 2025 09:57:07 +0900 Subject: [PATCH 4/7] =?UTF-8?q?refactor:=20flyway=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=8A=A4=ED=81=AC=EB=A6=BD=ED=8A=B8=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migration/V9__create_poll_and_vote_table.sql | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/resources/db/migration/V9__create_poll_and_vote_table.sql b/src/main/resources/db/migration/V9__create_poll_and_vote_table.sql index 1914c06e..c6663b89 100644 --- a/src/main/resources/db/migration/V9__create_poll_and_vote_table.sql +++ b/src/main/resources/db/migration/V9__create_poll_and_vote_table.sql @@ -2,20 +2,24 @@ CREATE TABLE poll ( id BIGINT AUTO_INCREMENT PRIMARY KEY, table_id BIGINT NOT NULL, - status VARCHAR(255) NOT NULL, + status VARCHAR(255) NOT NULL, pros_team_name VARCHAR(255) NOT NULL, cons_team_name VARCHAR(255) NOT NULL, - agenda TEXT, + agenda VARCHAR(255) NOT NULL, created_at DATETIME(6) NOT NULL, - updated_at DATETIME(6) NOT NULL + modified_at DATETIME(6) NOT NULL ); CREATE TABLE vote ( id BIGINT AUTO_INCREMENT PRIMARY KEY, poll_id BIGINT NOT NULL, - team VARCHAR(255) NOT NULL, + team VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, - participant_code VARCHAR(255) NOT NULL, - CONSTRAINT fk_vote_poll FOREIGN KEY (poll_id) REFERENCES poll (id) ON DELETE CASCADE + participant_code VARCHAR(255) NOT NULL ); + +alter table vote + add constraint vote_to_poll + foreign key (poll_id) + references poll (id); From eaadfbcc326943ed9889a2d1a0b942995eb68c07 Mon Sep 17 00:00:00 2001 From: coli Date: Thu, 10 Jul 2025 09:59:09 +0900 Subject: [PATCH 5/7] =?UTF-8?q?feat:=20=ED=88=AC=ED=91=9C=20=ED=8C=80=20En?= =?UTF-8?q?um=20value=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/debatetimer/domain/poll/VoteTeam.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/debatetimer/domain/poll/VoteTeam.java b/src/main/java/com/debatetimer/domain/poll/VoteTeam.java index e5dcface..d9648937 100644 --- a/src/main/java/com/debatetimer/domain/poll/VoteTeam.java +++ b/src/main/java/com/debatetimer/domain/poll/VoteTeam.java @@ -1,4 +1,8 @@ package com.debatetimer.domain.poll; public enum VoteTeam { + + PROS, + CONS, + ; } From ffc3ad3778158ae589a0f11e95292595b9a10250 Mon Sep 17 00:00:00 2001 From: coli Date: Thu, 10 Jul 2025 18:30:37 +0900 Subject: [PATCH 6/7] =?UTF-8?q?refactor:=20=EC=9D=BC=EA=B4=80=EC=84=B1?= =?UTF-8?q?=EC=97=90=20=EB=A7=9E=EB=8F=84=EB=A1=9D=20=ED=83=80=EC=9E=85=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../db/migration/V9__create_poll_and_vote_table.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/resources/db/migration/V9__create_poll_and_vote_table.sql b/src/main/resources/db/migration/V9__create_poll_and_vote_table.sql index c6663b89..9531c398 100644 --- a/src/main/resources/db/migration/V9__create_poll_and_vote_table.sql +++ b/src/main/resources/db/migration/V9__create_poll_and_vote_table.sql @@ -2,19 +2,19 @@ CREATE TABLE poll ( id BIGINT AUTO_INCREMENT PRIMARY KEY, table_id BIGINT NOT NULL, - status VARCHAR(255) NOT NULL, + status ENUM ('PROGRESS','DONE') NOT NULL, pros_team_name VARCHAR(255) NOT NULL, cons_team_name VARCHAR(255) NOT NULL, agenda VARCHAR(255) NOT NULL, - created_at DATETIME(6) NOT NULL, - modified_at DATETIME(6) NOT NULL + created_at TIMESTAMP NOT NULL, + modified_at TIMESTAMP NOT NULL ); CREATE TABLE vote ( id BIGINT AUTO_INCREMENT PRIMARY KEY, poll_id BIGINT NOT NULL, - team VARCHAR(255) NOT NULL, + team ENUM ('CONS','PROS') NOT NULL, name VARCHAR(255) NOT NULL, participant_code VARCHAR(255) NOT NULL ); From 8ac9fd2cd2683a7fc98303803044f5f1014890ea Mon Sep 17 00:00:00 2001 From: coli Date: Fri, 11 Jul 2025 00:27:16 +0900 Subject: [PATCH 7/7] =?UTF-8?q?refactor:=20default=20current=5Fstamp=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95=20=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/db/migration/V9__create_poll_and_vote_table.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/db/migration/V9__create_poll_and_vote_table.sql b/src/main/resources/db/migration/V9__create_poll_and_vote_table.sql index 9531c398..d5bf80ff 100644 --- a/src/main/resources/db/migration/V9__create_poll_and_vote_table.sql +++ b/src/main/resources/db/migration/V9__create_poll_and_vote_table.sql @@ -6,8 +6,8 @@ CREATE TABLE poll pros_team_name VARCHAR(255) NOT NULL, cons_team_name VARCHAR(255) NOT NULL, agenda VARCHAR(255) NOT NULL, - created_at TIMESTAMP NOT NULL, - modified_at TIMESTAMP NOT NULL + created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + modified_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ); CREATE TABLE vote