-
Notifications
You must be signed in to change notification settings - Fork 4
MySQL Foward Engineering
gyim1345 edited this page Oct 27, 2020
·
1 revision
-- MySQL Workbench Forward Engineering
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';
-- -----------------------------------------------------
-- Schema mydb
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema mydb
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET utf8 ;
USE `mydb` ;
-- -----------------------------------------------------
-- Table `mydb`.`user`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`user` (
`iduser` INT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(45) NOT NULL,
`profile_url` VARCHAR(45) NULL,
PRIMARY KEY (`iduser`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`milestones`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`milestones` (
`idmilestones` INT NOT NULL AUTO_INCREMENT,
`title` VARCHAR(45) NOT NULL,
`description` VARCHAR(45) NULL,
`due_date` DATE NULL DEFAULT NULL,
`status_open_closed` TINYINT NOT NULL,
PRIMARY KEY (`idmilestones`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`issues`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`issues` (
`idissues` INT NOT NULL AUTO_INCREMENT,
`labels` INT NULL,
`user_iduser` INT NOT NULL,
`milestones_idmilestones` INT NOT NULL,
`date` DATE NOT NULL,
`title` VARCHAR(45) NOT NULL,
`status_open_closed` TINYINT NOT NULL,
`content` LONGTEXT NULL,
PRIMARY KEY (`idissues`, `user_iduser`, `milestones_idmilestones`),
INDEX `fk_issues_user1_idx` (`user_iduser` ASC),
INDEX `fk_issues_milestones1_idx` (`milestones_idmilestones` ASC),
CONSTRAINT `fk_issues_user1`
FOREIGN KEY (`user_iduser`)
REFERENCES `mydb`.`user` (`iduser`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_issues_milestones1`
FOREIGN KEY (`milestones_idmilestones`)
REFERENCES `mydb`.`milestones` (`idmilestones`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`labels`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`labels` (
`idlabels` INT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(45) NOT NULL,
`color` VARCHAR(45) NOT NULL,
`description` VARCHAR(45) NULL,
PRIMARY KEY (`idlabels`))
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`comments`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`comments` (
`idcomments` INT NOT NULL AUTO_INCREMENT,
`comment` VARCHAR(45) NULL,
`date` DATE NULL,
`user_iduser` INT NOT NULL,
`issues_idissues` INT NOT NULL,
`issues_user_iduser` INT NOT NULL,
`issues_milestones_idmilestones` INT NOT NULL,
PRIMARY KEY (`idcomments`, `user_iduser`, `issues_idissues`, `issues_user_iduser`, `issues_milestones_idmilestones`),
INDEX `fk_comments_user1_idx` (`user_iduser` ASC),
INDEX `fk_comments_issues1_idx` (`issues_idissues` ASC, `issues_user_iduser` ASC, `issues_milestones_idmilestones` ASC),
CONSTRAINT `fk_comments_user1`
FOREIGN KEY (`user_iduser`)
REFERENCES `mydb`.`user` (`iduser`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_comments_issues1`
FOREIGN KEY (`issues_idissues` , `issues_user_iduser` , `issues_milestones_idmilestones`)
REFERENCES `mydb`.`issues` (`idissues` , `user_iduser` , `milestones_idmilestones`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`issues_has_labels`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`issues_has_labels` (
`issues_idissues` INT NOT NULL,
`labels_idlabels` INT NOT NULL,
PRIMARY KEY (`issues_idissues`, `labels_idlabels`),
INDEX `fk_issues_has_labels_labels1_idx` (`labels_idlabels` ASC),
INDEX `fk_issues_has_labels_issues_idx` (`issues_idissues` ASC),
CONSTRAINT `fk_issues_has_labels_issues`
FOREIGN KEY (`issues_idissues`)
REFERENCES `mydb`.`issues` (`idissues`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_issues_has_labels_labels1`
FOREIGN KEY (`labels_idlabels`)
REFERENCES `mydb`.`labels` (`idlabels`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`assignee`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`assignee` (
`idassignee` INT NOT NULL AUTO_INCREMENT,
`user_iduser` INT NOT NULL,
PRIMARY KEY (`idassignee`, `user_iduser`),
INDEX `fk_assignee_user1_idx` (`user_iduser` ASC),
CONSTRAINT `fk_assignee_user1`
FOREIGN KEY (`user_iduser`)
REFERENCES `mydb`.`user` (`iduser`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `mydb`.`issues_has_assignee`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `mydb`.`issues_has_assignee` (
`issues_idissues` INT NOT NULL,
`issues_user_iduser` INT NOT NULL,
`assignee_idassignee` INT NOT NULL,
PRIMARY KEY (`issues_idissues`, `issues_user_iduser`, `assignee_idassignee`),
INDEX `fk_issues_has_assignee_assignee1_idx` (`assignee_idassignee` ASC),
INDEX `fk_issues_has_assignee_issues1_idx` (`issues_idissues` ASC, `issues_user_iduser` ASC),
CONSTRAINT `fk_issues_has_assignee_issues1`
FOREIGN KEY (`issues_idissues` , `issues_user_iduser`)
REFERENCES `mydb`.`issues` (`idissues` , `user_iduser`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_issues_has_assignee_assignee1`
FOREIGN KEY (`assignee_idassignee`)
REFERENCES `mydb`.`assignee` (`idassignee`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
개발 일지
데일리 스크럼