Skip to content

Commit

Permalink
Merge pull request #20 from 2024-Iris/schema
Browse files Browse the repository at this point in the history
schema.sql 업데이트
  • Loading branch information
lvalentine6 authored Jun 6, 2024
2 parents fbd5894 + 892f172 commit aacd879
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 56 deletions.
36 changes: 18 additions & 18 deletions src/main/resources/data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,28 @@ INSERT INTO `user` (github_id, email)
VALUES ('lvalentine6', '[email protected]');

-- Inserting organizations
INSERT INTO `org` (name)
VALUES ('organization1');
INSERT INTO `org` (name)
VALUES ('organization2');
INSERT INTO `org` (name, gh_org_id)
VALUES ('organization1', 1);
INSERT INTO `org` (name, gh_org_id)
VALUES ('organization2', 2);

-- Inserting repositories
INSERT INTO `repository` (org_id, name)
VALUES (1, 'repo-a1');
INSERT INTO `repository` (org_id, name)
VALUES (1, 'repo-a2');
INSERT INTO `repository` (org_id, name)
VALUES (2, 'repob-1');
INSERT INTO `repository` (org_id, name, gh_repo_id)
VALUES (1, 'repo-a1', 1);
INSERT INTO `repository` (org_id, name, gh_repo_id)
VALUES (1, 'repo-a2', 2);
INSERT INTO `repository` (org_id, name, gh_repo_id)
VALUES (2, 'repob-1', 3);

-- Inserting issues
INSERT INTO `issue` (repository_id, name)
VALUES (1, 'issue-a1-1');
INSERT INTO `issue` (repository_id, name)
VALUES (1, 'issue-a1-2');
INSERT INTO `issue` (repository_id, name)
VALUES (2, 'issue-a2-1');
INSERT INTO `issue` (repository_id, name)
VALUES (3, 'issue-b1-1');
INSERT INTO `issue` (repository_id, title, gh_issue_number)
VALUES (1, 'issue-a1-1', 1234);
INSERT INTO `issue` (repository_id, title, gh_issue_number)
VALUES (1, 'issue-a1-2', 5678);
INSERT INTO `issue` (repository_id, title, gh_issue_number)
VALUES (2, 'issue-a2-1', 5679);
INSERT INTO `issue` (repository_id, title, gh_issue_number)
VALUES (3, 'issue-b1-1', 2000);

-- Inserting labels
INSERT INTO `label` (name)
Expand Down
148 changes: 110 additions & 38 deletions src/main/resources/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ SET @OLD_SQL_MODE = @@SQL_MODE, SQL_MODE =
-- -----------------------------------------------------
DROP SCHEMA IF EXISTS `issuefy`;

-- -----------------------------------------------------
-- Schema issuefy
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `issuefy` DEFAULT CHARACTER SET utf8;
USE `issuefy`;

Expand All @@ -26,86 +23,115 @@ DROP TABLE IF EXISTS `issuefy`.`user`;

CREATE TABLE IF NOT EXISTS `issuefy`.`user`
(
`id` BIGINT NOT NULL AUTO_INCREMENT,
`github_id` VARCHAR(255) NOT NULL,
`email` VARCHAR(255) NULL,
`id` BIGINT NOT NULL AUTO_INCREMENT,
`github_id` VARCHAR(255) NOT NULL,
`email` VARCHAR(255) NULL,
`alert_status` TINYINT NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE INDEX `login_id_UNIQUE` (`github_id` ASC) VISIBLE,
UNIQUE INDEX `email_UNIQUE` (`email` ASC) VISIBLE,
UNIQUE INDEX `id_UNIQUE` (`id` ASC) VISIBLE
UNIQUE INDEX `github_id_UNIQUE` (`github_id` ASC) VISIBLE,
UNIQUE INDEX `email_UNIQUE` (`email` ASC) VISIBLE
)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `issuefy`.`org`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `issuefy`.`org`;

CREATE TABLE IF NOT EXISTS `issuefy`.`org`
(
`id` BIGINT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(100) NULL,
PRIMARY KEY (`id`)
`id` BIGINT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(100) NULL,
`gh_org_id` BIGINT NOT NULL,
PRIMARY KEY (`id`),
UNIQUE INDEX `gh_org_id_UNIQUE` (`gh_org_id` ASC) VISIBLE
)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `issuefy`.`repository`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `issuefy`.`repository`;

CREATE TABLE IF NOT EXISTS `issuefy`.`repository`
(
`id` BIGINT NOT NULL AUTO_INCREMENT,
`org_id` BIGINT NOT NULL,
`name` VARCHAR(45) NULL,
`id` BIGINT NOT NULL AUTO_INCREMENT,
`org_id` BIGINT NOT NULL,
`name` VARCHAR(45) NULL,
`is_starred` TINYINT NOT NULL DEFAULT 0,
`gh_repo_id` BIGINT NOT NULL,
PRIMARY KEY (`id`),
INDEX `fk_repository_org1_idx` (`org_id` ASC) VISIBLE,
CONSTRAINT `fk_repository_org1`
INDEX `fk_repository_org_idx` (`org_id` ASC) VISIBLE,
UNIQUE INDEX `gh_repo_id_UNIQUE` (`gh_repo_id` ASC) VISIBLE,
CONSTRAINT `fk_repository_org`
FOREIGN KEY (`org_id`)
REFERENCES `issuefy`.`org` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION
ON DELETE CASCADE
ON UPDATE CASCADE
)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `issuefy`.`issue`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `issuefy`.`issue`;

CREATE TABLE IF NOT EXISTS `issuefy`.`issue`
(
`id` BIGINT NOT NULL AUTO_INCREMENT,
`repository_id` BIGINT NOT NULL,
`name` VARCHAR(45) NULL,
`id` BIGINT NOT NULL AUTO_INCREMENT,
`repository_id` BIGINT NOT NULL,
`title` VARCHAR(45) CHARACTER SET 'utf8mb4' NOT NULL,
`is_starred` TINYINT NOT NULL DEFAULT 0,
`is_read` TINYINT NOT NULL DEFAULT 0,
`gh_issue_number` BIGINT NOT NULL,
PRIMARY KEY (`id`),
INDEX `fk_issue_repository1_idx` (`repository_id` ASC) VISIBLE,
CONSTRAINT `fk_issue_repository1`
INDEX `fk_issue_repository_idx` (`repository_id` ASC) VISIBLE,
UNIQUE INDEX `gh_issue_number_UNIQUE` (`gh_issue_number` ASC) VISIBLE,
CONSTRAINT `fk_issue_repository`
FOREIGN KEY (`repository_id`)
REFERENCES `issuefy`.`repository` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION
ON DELETE CASCADE
ON UPDATE CASCADE
)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `issuefy`.`label`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `issuefy`.`label`;

CREATE TABLE IF NOT EXISTS `issuefy`.`label`
(
`id` BIGINT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(45) NULL,
`id` BIGINT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(45) CHARACTER SET 'utf8mb4' NOT NULL,
PRIMARY KEY (`id`)
)
ENGINE = InnoDB;

-- -----------------------------------------------------
-- Table `issuefy`.`issue_label`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `issuefy`.`issue_label`;

CREATE TABLE IF NOT EXISTS `issuefy`.`issue_label`
(
`issue_id` BIGINT NOT NULL,
`label_id` BIGINT NOT NULL,
PRIMARY KEY (`issue_id`, `label_id`),
INDEX `fk_issue_label_issue_idx` (`issue_id` ASC) VISIBLE,
INDEX `fk_issue_label_label_idx` (`label_id` ASC) VISIBLE,
CONSTRAINT `fk_issue_label_issue`
FOREIGN KEY (`issue_id`)
REFERENCES `issuefy`.`issue` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `fk_issue_label_label`
FOREIGN KEY (`label_id`)
REFERENCES `issuefy`.`label` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE
)
ENGINE = InnoDB;

-- -----------------------------------------------------
-- Table `issuefy`.`subscribe`
Expand All @@ -117,19 +143,65 @@ CREATE TABLE IF NOT EXISTS `issuefy`.`subscribe`
`id` BIGINT NOT NULL AUTO_INCREMENT,
`user_id` BIGINT NOT NULL,
`repository_id` BIGINT NOT NULL,
INDEX `fk_subscribe_repository1_idx` (`repository_id` ASC) VISIBLE,
INDEX `fk_subscribe_user1_idx` (`user_id` ASC) VISIBLE,
INDEX `fk_subscribe_repository_idx` (`repository_id` ASC) VISIBLE,
INDEX `fk_subscribe_user_idx` (`user_id` ASC) VISIBLE,
PRIMARY KEY (`id`),
CONSTRAINT `fk_subscribe_repository1`
CONSTRAINT `fk_subscribe_repository`
FOREIGN KEY (`repository_id`)
REFERENCES `issuefy`.`repository` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_subscribe_user1`
CONSTRAINT `fk_subscribe_user`
FOREIGN KEY (`user_id`)
REFERENCES `issuefy`.`user` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION
ON DELETE CASCADE
ON UPDATE CASCADE
)
ENGINE = InnoDB;

-- -----------------------------------------------------
-- Table `issuefy`.`notification`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `issuefy`.`notification`;

CREATE TABLE IF NOT EXISTS `issuefy`.`notification`
(
`id` BIGINT NOT NULL AUTO_INCREMENT,
`issue_id` BIGINT NOT NULL,
`title` VARCHAR(45) CHARACTER SET 'utf8mb4' NOT NULL,
`is_read` TINYINT NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
INDEX `fk_notification_issue_idx` (`issue_id` ASC) VISIBLE,
CONSTRAINT `fk_notification_issue`
FOREIGN KEY (`issue_id`)
REFERENCES `issuefy`.`issue` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE
)
ENGINE = InnoDB;

-- -----------------------------------------------------
-- Table `issuefy`.`user_notification`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `issuefy`.`user_notification`;

CREATE TABLE IF NOT EXISTS `issuefy`.`user_notification`
(
`user_id` BIGINT NOT NULL,
`notification_id` BIGINT NOT NULL,
PRIMARY KEY (`user_id`, `notification_id`),
INDEX `fk_user_notification_user_idx` (`user_id` ASC) VISIBLE,
INDEX `fk_user_notification_notification_idx` (`notification_id` ASC) VISIBLE,
CONSTRAINT `fk_user_notification_user`
FOREIGN KEY (`user_id`)
REFERENCES `issuefy`.`user` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `fk_user_notification_notification`
FOREIGN KEY (`notification_id`)
REFERENCES `issuefy`.`notification` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE
)
ENGINE = InnoDB;

Expand Down

0 comments on commit aacd879

Please sign in to comment.