Skip to content

Commit

Permalink
feat: updated database create query
Browse files Browse the repository at this point in the history
  • Loading branch information
mjkweon17 committed Mar 23, 2024
1 parent 7973051 commit 6fcce35
Showing 1 changed file with 6 additions and 20 deletions.
26 changes: 6 additions & 20 deletions create_tables.sql
Original file line number Diff line number Diff line change
@@ -1,29 +1,15 @@
# 수정 필요

CREATE TABLE `Page` (
`page_id` INT AUTO_INCREMENT NOT NULL, `title` VARCHAR(255) NOT NULL, `url` VARCHAR(2083) NOT NULL, `summary` TEXT NOT NULL, `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), `state` TINYINT NOT NULL DEFAULT 1
`page_id` INT AUTO_INCREMENT NOT NULL, `title` VARCHAR(255) NOT NULL, `url` VARCHAR(2083) NOT NULL, `summary` TEXT NOT NULL, `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), `state` TINYINT NOT NULL DEFAULT 1, PRIMARY KEY (`page_id`)
);

CREATE TABLE `User` (
`user_id` INT AUTO_INCREMENT NOT NULL, `auth_id` BIGINT NOT NULL, `email` VARCHAR(255) NOT NULL, `user_name` VARCHAR(255) NOT NULL, `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), `state` TINYINT NOT NULL DEFAULT 1, `access_token` VARCHAR(255) NULL, `token_type` VARCHAR(255) NULL, `expires_in` VARCHAR(255) NULL, `refresh_token` VARCHAR(255) NULL, `scope` VARCHAR(255) NULL, `id_token` VARCHAR(255) NULL
`user_id` INT AUTO_INCREMENT NOT NULL, `auth_id` BIGINT NOT NULL, `email` VARCHAR(255) NOT NULL, `user_name` VARCHAR(255) NOT NULL, `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), `state` TINYINT NOT NULL DEFAULT 1, `access_token` VARCHAR(255) NULL, `token_type` VARCHAR(255) NULL, `expires_in` VARCHAR(255) NULL, `refresh_token` VARCHAR(255) NULL, `scope` VARCHAR(255) NULL, `id_token` VARCHAR(255) NULL, PRIMARY KEY (`user_id`)
);

CREATE TABLE `Bookmark` (
`bookmark_id` INT AUTO_INCREMENT NOT NULL, `page_id` INT NOT NULL, `user_id` INT NOT NULL, `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), `state` TINYINT NOT NULL DEFAULT 1
);

CREATE TABLE `MDContent` (
`content_id` INT AUTO_INCREMENT NOT NULL, `user_id` INT NULL DEFAULT 0, `content` TEXT NOT NULL, `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), `updated_at` DATETIME(3) NOT NULL DEFAULT ON UPDATE CURRENT_TIMESTAMP(3), `state` TINYINT NOT NULL DEFAULT 1
`bookmark_id` INT AUTO_INCREMENT NOT NULL, `page_id` INT NOT NULL, `user_id` INT NOT NULL, `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), `state` TINYINT NOT NULL DEFAULT 1, PRIMARY KEY (`bookmark_id`), FOREIGN KEY (`page_id`) REFERENCES `Page` (`page_id`), FOREIGN KEY (`user_id`) REFERENCES `User` (`user_id`)
);

ALTER TABLE `Page`
ADD CONSTRAINT `PK_PAGE` PRIMARY KEY (`page_id`);

ALTER TABLE `User`
ADD CONSTRAINT `PK_USER` PRIMARY KEY (`user_id`);

ALTER TABLE `Bookmark`
ADD CONSTRAINT `PK_BOOKMARK` PRIMARY KEY (`bookmark_id`);

ALTER TABLE `MDContent`
ADD CONSTRAINT `PK_MDCONTENT` PRIMARY KEY (`content_id`);
CREATE TABLE `Content` (
`content_id` INT AUTO_INCREMENT NOT NULL, `user_id` INT NULL DEFAULT 0, `content` TEXT NOT NULL, `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), `updated_at` DATETIME(3) NOT NULL DEFAULT ON UPDATE CURRENT_TIMESTAMP(3), `state` TINYINT NOT NULL DEFAULT 1, PRIMARY KEY (`content_id`), FOREIGN KEY (`user_id`) REFERENCES `User` (`user_id`)
);

0 comments on commit 6fcce35

Please sign in to comment.