Skip to content

Commit

Permalink
imp: sql scripts 분리
Browse files Browse the repository at this point in the history
  • Loading branch information
DongGeon0908 committed Aug 21, 2024
1 parent 1c8305b commit 61c10c4
Show file tree
Hide file tree
Showing 5 changed files with 189 additions and 193 deletions.
193 changes: 0 additions & 193 deletions sql/DDL.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,122 +2,6 @@
CREATE
DATABASE hero CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;

-- 유저 정보
CREATE TABLE `user_info`
(
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'user id',
`nickname` varchar(64) NOT NULL COMMENT '닉네임',
`created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '생성일',
`modified_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '수정일',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=200000 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='유저 정보';
CREATE UNIQUE INDEX uidx__nickname ON user_info (nickname);

-- 일반 회원가입 유저 정보
CREATE TABLE `credential_user_info`
(
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'credential_user_info id',
`uid` bigint NOT NULL COMMENT 'user id',
`username` varchar(256) NOT NULL COMMENT '로그인 id',
`password` varchar(512) NOT NULL COMMENT '로그인 pw',
`created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '생성일',
`modified_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '수정일',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=200000 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='유저 정보';
CREATE UNIQUE INDEX uidx__uid ON credential_user_info (uid);
CREATE UNIQUE INDEX uidx__username ON credential_user_info (username);

-- OAuth 회원가입 유저 정보
CREATE TABLE `oauth_user_info`
(
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'oauth user info id',
`uid` bigint NOT NULL COMMENT 'user id',
`provider` varchar(32) NOT NULL COMMENT 'oauth provider',
`oauth_id` varchar(512) NOT NULL COMMENT 'oauth id',
`created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '생성일',
`modified_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '수정일',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=200000 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='oauth 유저 정보';
CREATE UNIQUE INDEX uidx__uid__provider ON oauth_user_info (uid, provider);
CREATE INDEX idx__oauth_id__provider ON oauth_user_info (oauth_id, provider);

-- 그룹
CREATE TABLE `group`
(
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'group id',
`name` varchar(32) NOT NULL COMMENT '그룹명',
`description` varchar(512) DEFAULT NULL COMMENT '그룹 설명',
`owner_uid` bigint NOT NULL COMMENT 'owner uid',
`is_hidden` tinyint NOT NULL DEFAULT 0 COMMENT '숨김 여부',
`join_code` varchar(128) DEFAULT NULL COMMENT '참여코드',
`user_count` int NOT NULL DEFAULT 1 COMMENT '그룹원 수',
`user_capacity` int NOT NULL DEFAULT 0 COMMENT '그룹원 정원',
`created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '생성일',
`modified_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '수정일',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=200000 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='그룹';

CREATE UNIQUE INDEX uidx__name ON `group` (name);
CREATE INDEX idx__owner_uid ON `group` (owner_uid);
CREATE INDEX idx__join_code ON `group` (join_code);

-- 그룹 유저
CREATE TABLE `group_user`
(
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'group user id',
`group_id` bigint NOT NULL COMMENT 'group id',
`uid` bigint NOT NULL COMMENT 'uid',
`created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '생성일',
`modified_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '수정일',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=200000 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='그룹 유저';
CREATE UNIQUE INDEX uidx__group_id__uid ON group_user (group_id, uid);
CREATE INDEX idx__uid ON group_user (uid);

-- 그룹 유저 스코어
CREATE TABLE `group_user_score`
(
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'group user score id',
`group_id` bigint NOT NULL COMMENT 'group id',
`group_user_id` bigint NOT NULL COMMENT 'group user id',
`uid` bigint NOT NULL COMMENT 'uid',
`score` int DEFAULT NULL COMMENT '스코어',
`created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '생성일',
`modified_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '수정일',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=200000 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='그룹 유저 스코어';
CREATE UNIQUE INDEX uidx__group_user_id ON group_user_score (group_user_id);
CREATE INDEX idx__group_id__group_user_id ON group_user_score (group_id, group_user_id);
CREATE INDEX idx__uid ON group_user_score (uid);

-- 포즈 스냅샵
CREATE TABLE `pose_snapshot`
(
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'pose snapshot id',
`uid` bigint NOT NULL COMMENT 'uid',
`score` DECIMAL(20, 16) NOT NULL COMMENT '포즈 신뢰도 종합',
`type` VARCHAR(32) NOT NULL COMMENT '포즈 타입',
`image_url` VARCHAR(512) NOT NULL COMMENT '포즈 이미지 url',
`created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '생성일',
`modified_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '수정일',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='포즈 스냅샷';
CREATE INDEX idx__uid ON pose_snapshot (uid);
CREATE INDEX idx__created_at ON pose_snapshot (created_at);

-- 포즈 key point 스냅샷
CREATE TABLE `pose_key_point_snapshot`
(
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'pose key point snapshot id',
`pose_snapshot_id` bigint NOT NULL COMMENT 'post snapshot id',
`position` VARCHAR(32) NOT NULL COMMENT '스냅샷 위치',
`x` DECIMAL(20, 16) NOT NULL COMMENT 'x 좌표',
`y` DECIMAL(20, 16) NOT NULL COMMENT 'y 좌표',
`confidence` DECIMAL(20, 16) NOT NULL COMMENT '신뢰도'
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='포즈 key point';
CREATE INDEX uidx__pose_snapshot_id__position ON pose_key_point_snapshot (pose_snapshot_id, position);

-- system log
CREATE TABLE `system_action_log`
(
Expand Down Expand Up @@ -147,80 +31,3 @@ CREATE TABLE `image_metadata`
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=200000 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
CREATE INDEX idx__uid__type ON image_metadata (uid, type);

-- 문의하기
CREATE TABLE `discussion`
(
`id` bigint NOT NULL AUTO_INCREMENT,
`uid` bigint NOT NULL COMMENT 'uid',
`type` varchar(32) NOT NULL COMMENT '문의하기 유형',
`title` varchar(512) NOT NULL COMMENT '문의하기 제목',
`content` text NOT NULL COMMENT '문의하기 본문',
`created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '생성일',
`modified_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '수정일',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=200000 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
CREATE INDEX idx__uid ON discussion (uid);

-- 문의하기 답변
CREATE TABLE `discussion_comment`
(
`id` bigint NOT NULL AUTO_INCREMENT,
`uid` bigint NOT NULL COMMENT 'uid',
`discussion_id` bigint NOT NULL COMMENT 'discussion_id',
`title` varchar(512) NOT NULL COMMENT '답변 제목',
`content` text NOT NULL COMMENT '답변 본문',
`created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '생성일',
`modified_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '수정일',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=200000 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
CREATE INDEX idx__discussion_id ON discussion_comment (discussion_id);
CREATE INDEX idx__uid ON discussion_comment (uid);

-- 포즈 카운트 집계
CREATE TABLE `pose_count`
(
`id` bigint NOT NULL AUTO_INCREMENT,
`uid` bigint NOT NULL COMMENT 'uid',
`total_count` text NOT NULL COMMENT '집계 데이터',
`date` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '기준 날짜',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
CREATE INDEX idx__uid__date ON pose_count (uid, date);
CREATE INDEX idx__date ON pose_count (date);

-- 자세 알림
CREATE TABLE `pose_noti`
(
`id` bigint NOT NULL AUTO_INCREMENT,
`uid` bigint NOT NULL COMMENT 'uid',
`is_active` tinyint NOT NULL DEFAULT 0 COMMENT '활성화 여부',
`duration` varchar(32) NOT NULL COMMENT '알림 주기',
`created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '생성일',
`modified_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '수정일',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT '자세 알림';
CREATE INDEX uidx__uid ON pose_noti (uid);

-- 포즈 레이아웃
CREATE TABLE `pose_layout`
(
`id` bigint NOT NULL AUTO_INCREMENT,
`uid` bigint NOT NULL COMMENT 'uid',
`created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '생성일',
`modified_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '수정일',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT '포즈 레이아웃';
CREATE INDEX idx__uid ON pose_layout (uid);

-- 포즈 레이아웃 포인트
CREATE TABLE `pose_layout_point`
(
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'pose key point snapshot id',
`pose_layout_id` bigint NOT NULL COMMENT 'pose layout id',
`position` VARCHAR(32) NOT NULL COMMENT '스냅샷 위치',
`x` DECIMAL(20, 16) NOT NULL COMMENT 'x 좌표',
`y` DECIMAL(20, 16) NOT NULL COMMENT 'y 좌표',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='포즈 레이아웃 point';
CREATE INDEX uidx__pose_snapshot_id__position ON pose_layout_point (pose_layout_id, position);
28 changes: 28 additions & 0 deletions sql/discussion.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-- 문의하기
CREATE TABLE `discussion`
(
`id` bigint NOT NULL AUTO_INCREMENT,
`uid` bigint NOT NULL COMMENT 'uid',
`type` varchar(32) NOT NULL COMMENT '문의하기 유형',
`title` varchar(512) NOT NULL COMMENT '문의하기 제목',
`content` text NOT NULL COMMENT '문의하기 본문',
`created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '생성일',
`modified_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '수정일',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=200000 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
CREATE INDEX idx__uid ON discussion (uid);

-- 문의하기 답변
CREATE TABLE `discussion_comment`
(
`id` bigint NOT NULL AUTO_INCREMENT,
`uid` bigint NOT NULL COMMENT 'uid',
`discussion_id` bigint NOT NULL COMMENT 'discussion_id',
`title` varchar(512) NOT NULL COMMENT '답변 제목',
`content` text NOT NULL COMMENT '답변 본문',
`created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '생성일',
`modified_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '수정일',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=200000 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
CREATE INDEX idx__discussion_id ON discussion_comment (discussion_id);
CREATE INDEX idx__uid ON discussion_comment (uid);
48 changes: 48 additions & 0 deletions sql/group.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
-- 그룹
CREATE TABLE `group`
(
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'group id',
`name` varchar(32) NOT NULL COMMENT '그룹명',
`description` varchar(512) DEFAULT NULL COMMENT '그룹 설명',
`owner_uid` bigint NOT NULL COMMENT 'owner uid',
`is_hidden` tinyint NOT NULL DEFAULT 0 COMMENT '숨김 여부',
`join_code` varchar(128) DEFAULT NULL COMMENT '참여코드',
`user_count` int NOT NULL DEFAULT 1 COMMENT '그룹원 수',
`user_capacity` int NOT NULL DEFAULT 0 COMMENT '그룹원 정원',
`created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '생성일',
`modified_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '수정일',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=200000 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='그룹';

CREATE UNIQUE INDEX uidx__name ON `group` (name);
CREATE INDEX idx__owner_uid ON `group` (owner_uid);
CREATE INDEX idx__join_code ON `group` (join_code);

-- 그룹 유저
CREATE TABLE `group_user`
(
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'group user id',
`group_id` bigint NOT NULL COMMENT 'group id',
`uid` bigint NOT NULL COMMENT 'uid',
`created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '생성일',
`modified_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '수정일',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=200000 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='그룹 유저';
CREATE UNIQUE INDEX uidx__group_id__uid ON group_user (group_id, uid);
CREATE INDEX idx__uid ON group_user (uid);

-- 그룹 유저 스코어
CREATE TABLE `group_user_score`
(
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'group user score id',
`group_id` bigint NOT NULL COMMENT 'group id',
`group_user_id` bigint NOT NULL COMMENT 'group user id',
`uid` bigint NOT NULL COMMENT 'uid',
`score` int DEFAULT NULL COMMENT '스코어',
`created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '생성일',
`modified_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '수정일',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=200000 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='그룹 유저 스코어';
CREATE UNIQUE INDEX uidx__group_user_id ON group_user_score (group_user_id);
CREATE INDEX idx__group_id__group_user_id ON group_user_score (group_id, group_user_id);
CREATE INDEX idx__uid ON group_user_score (uid);
75 changes: 75 additions & 0 deletions sql/pose.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
-- 포즈 스냅샵
CREATE TABLE `pose_snapshot`
(
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'pose snapshot id',
`uid` bigint NOT NULL COMMENT 'uid',
`score` DECIMAL(20, 16) NOT NULL COMMENT '포즈 신뢰도 종합',
`type` VARCHAR(32) NOT NULL COMMENT '포즈 타입',
`image_url` VARCHAR(512) NOT NULL COMMENT '포즈 이미지 url',
`created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '생성일',
`modified_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '수정일',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='포즈 스냅샷';
CREATE INDEX idx__uid ON pose_snapshot (uid);
CREATE INDEX idx__created_at ON pose_snapshot (created_at);

-- 포즈 key point 스냅샷
CREATE TABLE `pose_key_point_snapshot`
(
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'pose key point snapshot id',
`pose_snapshot_id` bigint NOT NULL COMMENT 'post snapshot id',
`position` VARCHAR(32) NOT NULL COMMENT '스냅샷 위치',
`x` DECIMAL(20, 16) NOT NULL COMMENT 'x 좌표',
`y` DECIMAL(20, 16) NOT NULL COMMENT 'y 좌표',
`confidence` DECIMAL(20, 16) NOT NULL COMMENT '신뢰도'
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='포즈 key point';
CREATE INDEX uidx__pose_snapshot_id__position ON pose_key_point_snapshot (pose_snapshot_id, position);

-- 포즈 카운트 집계
CREATE TABLE `pose_count`
(
`id` bigint NOT NULL AUTO_INCREMENT,
`uid` bigint NOT NULL COMMENT 'uid',
`total_count` text NOT NULL COMMENT '집계 데이터',
`date` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '기준 날짜',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
CREATE INDEX idx__uid__date ON pose_count (uid, date);
CREATE INDEX idx__date ON pose_count (date);

-- 자세 알림
CREATE TABLE `pose_noti`
(
`id` bigint NOT NULL AUTO_INCREMENT,
`uid` bigint NOT NULL COMMENT 'uid',
`is_active` tinyint NOT NULL DEFAULT 0 COMMENT '활성화 여부',
`duration` varchar(32) NOT NULL COMMENT '알림 주기',
`created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '생성일',
`modified_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '수정일',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT '자세 알림';
CREATE INDEX uidx__uid ON pose_noti (uid);

-- 포즈 레이아웃
CREATE TABLE `pose_layout`
(
`id` bigint NOT NULL AUTO_INCREMENT,
`uid` bigint NOT NULL COMMENT 'uid',
`created_at` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '생성일',
`modified_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '수정일',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT '포즈 레이아웃';
CREATE INDEX idx__uid ON pose_layout (uid);

-- 포즈 레이아웃 포인트
CREATE TABLE `pose_layout_point`
(
`id` bigint NOT NULL AUTO_INCREMENT COMMENT 'pose key point snapshot id',
`pose_layout_id` bigint NOT NULL COMMENT 'pose layout id',
`position` VARCHAR(32) NOT NULL COMMENT '스냅샷 위치',
`x` DECIMAL(20, 16) NOT NULL COMMENT 'x 좌표',
`y` DECIMAL(20, 16) NOT NULL COMMENT 'y 좌표',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='포즈 레이아웃 point';
CREATE INDEX uidx__pose_snapshot_id__position ON pose_layout_point (pose_layout_id, position);
Loading

0 comments on commit 61c10c4

Please sign in to comment.