Skip to content

Commit

Permalink
feat(Vote): 투표 Schema DDL 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
JoosungKwon committed Aug 6, 2023
1 parent d413223 commit b2d7927
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static jakarta.persistence.GenerationType.*;
import static lombok.AccessLevel.*;

import java.time.LocalDateTime;
import java.util.List;

import com.clover.habbittracker.global.base.entity.BaseEntity;
Expand All @@ -27,9 +28,9 @@ public class Vote extends BaseEntity {

private String title;

private String description;

@OneToMany(mappedBy = "vote")
private List<VoteItem> voteItemList;

private LocalDateTime deadline;

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import lombok.Getter;
Expand All @@ -25,9 +26,10 @@ public class VoteItem {

private Integer count;

private Integer order;
private Integer seq;

@ManyToOne
@JoinColumn(name = "vote_id")
private Vote vote;

}
24 changes: 24 additions & 0 deletions src/main/resources/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
-- create schema habiters-db;
-- use habiters-db;

DROP TABLE IF EXISTS vote_item;
DROP TABLE IF EXISTS vote;
DROP TABLE IF EXISTS bookmark_folder;
DROP TABLE IF EXISTS bookmark;
DROP TABLE IF EXISTS emoji;
Expand Down Expand Up @@ -123,3 +125,25 @@ create table bookmark_folder
bookmark_id bigint not null,
posts_id bigint null
);

create table vote
(
id bigint auto_increment primary key,
title varchar(255) not null,
deadline datetime(6) not null,
created_date datetime(6) not null default CURRENT_TIMESTAMP(6),
updated_date datetime(6) not null default CURRENT_TIMESTAMP(6),
deleted boolean not null default false
);

create table vote_item
(
id bigint auto_increment primary key,
content varchar(255) not null,
count int not null default 0,
seq int not null default 1,
vote_id bigint not null,

constraint vote_item_vote_id_fk
foreign key (vote_id) references vote (id)
);

0 comments on commit b2d7927

Please sign in to comment.