forked from codesquad-2023-group04/issue-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ADD: DB 스키마 추가 (codesquad-2023-group04#27)
- Loading branch information
1 parent
edf4455
commit 476cd15
Showing
1 changed file
with
214 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,214 @@ | ||
DROP TABLE milestone if exist; | ||
CREATE TABLE milestone ( | ||
milestone_id bigint not null auto increment primary key, | ||
title varchar(1000) not null, | ||
description varchar(3000) null, | ||
datetime date | ||
); | ||
CREATE TABLE `milestone` | ||
( | ||
`milestone_id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT, | ||
`title` VARCHAR(45) NOT NULL, | ||
`description` VARCHAR(300) NULL, | ||
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
`is_delete` TINYINT NOT NULL DEFAULT 0 | ||
); | ||
|
||
|
||
|
||
CREATE TABLE `member` | ||
( | ||
`member_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, | ||
`login_id` VARCHAR(45) NOT NULL UNIQUE, | ||
`member_name` VARCHAR(45) NOT NULL, | ||
`password` VARCHAR(45) NOT NULL, | ||
`email` VARCHAR(45) NOT NULL, | ||
`profile_url` VARCHAR(300) NULL | ||
); | ||
|
||
|
||
|
||
CREATE TABLE `issue` | ||
( | ||
`issue_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, | ||
`title` VARCHAR(45) NOT NULL, | ||
`contents` TEXT(30000) NULL, | ||
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
`update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | ||
`is_open` TINYINT NOT NULL DEFAULT 1, | ||
`is_delete` TINYINT NOT NULL DEFAULT 0, | ||
`milestone_id` INT NULL, | ||
`author` INT NOT NULL, | ||
|
||
CONSTRAINT `fk_Issue_Milestone1` | ||
FOREIGN KEY (`milestone_id`) | ||
REFERENCES `milestone` (`milestone_id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION, | ||
|
||
CONSTRAINT `fk_Issue_User1` | ||
FOREIGN KEY (`author`) | ||
REFERENCES `member` (`member_id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION | ||
|
||
); | ||
|
||
|
||
|
||
CREATE TABLE `label` | ||
( | ||
`label_id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT, | ||
`title` VARCHAR(45) NOT NULL, | ||
`description` VARCHAR(300) NOT NULL, | ||
`is_delete` TINYINT NOT NULL DEFAULT 0, | ||
`background_color` VARCHAR(45) NOT NULL | ||
); | ||
|
||
|
||
|
||
CREATE TABLE `comment` | ||
( | ||
`comment_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, | ||
`contents` VARCHAR(45) NOT NULL, | ||
`update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
`create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | ||
`issue_id` INT NOT NULL, | ||
`member_id` INT NOT NULL, | ||
|
||
CONSTRAINT `fk_Comment_Issue1` | ||
FOREIGN KEY (`issue_id`) | ||
REFERENCES `issue` (`issue_id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION, | ||
CONSTRAINT `fk_comment_user1` | ||
FOREIGN KEY (`member_id`) | ||
REFERENCES `member` (`member_id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION | ||
); | ||
|
||
|
||
|
||
CREATE TABLE `label_list` | ||
( | ||
`label_id` INT NOT NULL, | ||
`issue_id` INT NOT NULL, | ||
PRIMARY KEY (`label_id`, `issue_id`), | ||
|
||
CONSTRAINT `fk_Label_has_Issue_Label1` | ||
FOREIGN KEY (`label_id`) | ||
REFERENCES `label` (`label_id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION, | ||
CONSTRAINT `fk_Label_has_Issue_Issue1` | ||
FOREIGN KEY (`issue_id`) | ||
REFERENCES `issue` (`issue_id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION | ||
); | ||
|
||
|
||
|
||
CREATE TABLE `assignee` | ||
( | ||
`member_id` INT NOT NULL, | ||
`issue_id` INT NOT NULL, | ||
PRIMARY KEY (`member_id`, `issue_id`), | ||
|
||
CONSTRAINT `fk_User_has_Issue_User1` | ||
FOREIGN KEY (`member_id`) | ||
REFERENCES `member` (`member_id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION, | ||
CONSTRAINT `fk_User_has_Issue_Issue1` | ||
FOREIGN KEY (`issue_id`) | ||
REFERENCES `issue` (`issue_id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION | ||
); | ||
|
||
|
||
|
||
CREATE TABLE `file` | ||
( | ||
`file_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, | ||
`file_url` VARCHAR(300) NULL | ||
); | ||
|
||
|
||
|
||
CREATE TABLE `emoji` | ||
( | ||
`emoji_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, | ||
`emoji_shpape` VARCHAR(45) NULL, | ||
`emoji_count` INT NULL | ||
); | ||
|
||
|
||
CREATE TABLE `issue_file_list` | ||
( | ||
`issue_id` INT NOT NULL, | ||
`file_id` INT NOT NULL, | ||
PRIMARY KEY (`issue_id`, `file_id`), | ||
|
||
CONSTRAINT `fk_issue_has_file_issue1` | ||
FOREIGN KEY (`issue_id`) | ||
REFERENCES `issue` (`issue_id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION, | ||
CONSTRAINT `fk_issue_has_file_file1` | ||
FOREIGN KEY (`file_id`) | ||
REFERENCES `file` (`file_id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION | ||
); | ||
|
||
|
||
CREATE TABLE `comment_file_list` | ||
( | ||
`file_id` INT NOT NULL, | ||
`comment_id` INT NOT NULL, | ||
PRIMARY KEY (`file_id`, `comment_id`), | ||
CONSTRAINT `fk_file_has_comment_file1` | ||
FOREIGN KEY (`file_id`) | ||
REFERENCES `file` (`file_id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION, | ||
CONSTRAINT `fk_file_has_comment_comment1` | ||
FOREIGN KEY (`comment_id`) | ||
REFERENCES `comment` (`comment_id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION | ||
); | ||
|
||
|
||
CREATE TABLE `comment_emoji_list` | ||
( | ||
`emoji_id` INT NOT NULL, | ||
`comment_id` INT NOT NULL, | ||
PRIMARY KEY (`emoji_id`, `comment_id`), | ||
|
||
CONSTRAINT `fk_emoji_has_comment_emoji1` | ||
FOREIGN KEY (`emoji_id`) | ||
REFERENCES `emoji` (`emoji_id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION, | ||
CONSTRAINT `fk_emoji_has_comment_comment1` | ||
FOREIGN KEY (`comment_id`) | ||
REFERENCES `comment` (`comment_id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION | ||
); | ||
|
||
|
||
CREATE TABLE `issue_emoji_list` | ||
( | ||
`issue_issue_id` INT NOT NULL, | ||
`emoji_emoji_id` INT NOT NULL, | ||
PRIMARY KEY (`issue_issue_id`, `emoji_emoji_id`), | ||
|
||
CONSTRAINT `fk_issue_has_emoji_issue1` | ||
FOREIGN KEY (`issue_issue_id`) | ||
REFERENCES `issue` (`issue_id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION, | ||
CONSTRAINT `fk_issue_has_emoji_emoji1` | ||
FOREIGN KEY (`emoji_emoji_id`) | ||
REFERENCES `emoji` (`emoji_id`) | ||
ON DELETE NO ACTION | ||
ON UPDATE NO ACTION | ||
); |