Skip to content

Commit f95426d

Browse files
authored
Merge pull request #527 from TaskFlow-CLAP/CLAP-405
CLAP-405 운영환경 초기 스키마 설정
2 parents f174d22 + e3683a5 commit f95426d

File tree

3 files changed

+237
-2
lines changed

3 files changed

+237
-2
lines changed
Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
create table api_log (
2+
dtype varchar(31) not null,
3+
log_id bigint not null auto_increment,
4+
client_ip varchar(255) not null,
5+
request_url varchar(4096) not null,
6+
request_method enum ('DELETE','GET','PATCH','POST','PUT','UNKNOWN') not null,
7+
status_code integer not null,
8+
custom_status_code varchar(255) not null,
9+
request_body TEXT not null,
10+
response_body TEXT not null,
11+
request_at datetime(6) not null,
12+
log_status enum ('ASSIGNER_CHANGED','COMMENT_ADDED','COMMENT_UPDATED','LOGIN','REQUEST_APPROVED','REQUEST_CANCELLED','REQUEST_CREATED','REQUEST_UPDATED','STATUS_CHANGED','TASK_VIEWED') not null,
13+
version bigint,
14+
member_id bigint,
15+
login_nickname varchar(255),
16+
created_at datetime(6) not null,
17+
updated_at datetime(6) not null,
18+
primary key (log_id)
19+
) engine=InnoDB;
20+
21+
create table attachment (
22+
attachment_id bigint not null auto_increment,
23+
original_name varchar(255) not null,
24+
task_id bigint,
25+
file_url varchar(255) not null,
26+
file_size varchar(255) not null,
27+
is_deleted bit not null,
28+
created_at datetime(6) not null,
29+
updated_at datetime(6) not null,
30+
primary key (attachment_id)
31+
) engine=InnoDB;
32+
33+
create table category (
34+
category_id bigint not null auto_increment,
35+
admin_id bigint not null,
36+
code varchar(255) not null,
37+
name varchar(255) not null,
38+
main_category_id bigint,
39+
is_deleted bit not null,
40+
description_example varchar(255),
41+
created_at datetime(6) not null,
42+
updated_at datetime(6) not null,
43+
primary key (category_id)
44+
) engine=InnoDB;
45+
46+
create table comment (
47+
comment_id bigint not null auto_increment,
48+
member_id bigint not null,
49+
task_id bigint not null,
50+
content varchar(255),
51+
original_name varchar(255),
52+
file_size varchar(255),
53+
file_url varchar(255),
54+
is_modified bit not null,
55+
is_deleted bit not null,
56+
created_at datetime(6) not null,
57+
updated_at datetime(6) not null,
58+
primary key (comment_id)
59+
) engine=InnoDB;
60+
61+
create table department (
62+
department_id bigint not null auto_increment,
63+
admin_id bigint,
64+
name varchar(255) not null,
65+
status enum ('ACTIVE','INACTIVE') not null,
66+
is_manager bit not null,
67+
created_at datetime(6) not null,
68+
updated_at datetime(6) not null,
69+
primary key (department_id)
70+
) engine=InnoDB;
71+
72+
create table label (
73+
label_id bigint not null auto_increment,
74+
admin_id bigint not null,
75+
label_name varchar(255) not null,
76+
label_color enum ('BLUE','GREEN','GREY','INDIGO','ORANGE','PURPLE','RED','YELLOW') not null,
77+
is_deleted bit not null,
78+
created_at datetime(6) not null,
79+
updated_at datetime(6) not null,
80+
primary key (label_id)
81+
) engine=InnoDB;
82+
83+
create table member (
84+
member_id bigint not null auto_increment,
85+
name varchar(255) not null,
86+
nickname varchar(255) not null,
87+
password varchar(255),
88+
image_url varchar(255),
89+
email varchar(255) not null,
90+
role enum ('ROLE_ADMIN','ROLE_MANAGER','ROLE_USER') not null,
91+
status enum ('ACTIVE','APPROVAL_REQUEST','DELETED','INACTIVE','PENDING') not null,
92+
is_reviewer bit not null,
93+
department_role varchar(255),
94+
admin_id bigint,
95+
department_id bigint,
96+
created_at datetime(6) not null,
97+
updated_at datetime(6) not null,
98+
email_notification_enabled bit,
99+
kakaowork_notification_enabled bit,
100+
in_progress_task_count integer,
101+
in_reviewing_task_count integer,
102+
primary key (member_id)
103+
) engine=InnoDB;
104+
105+
create table notification (
106+
notification_id bigint not null auto_increment,
107+
is_read bit not null,
108+
message varchar(255),
109+
task_title varchar(255) not null,
110+
receiver_id bigint not null,
111+
task_id bigint,
112+
type enum ('COMMENT','INVITATION','PROCESSOR_ASSIGNED','PROCESSOR_CHANGED','STATUS_SWITCHED','TASK_REQUESTED') not null,
113+
created_at datetime(6) not null,
114+
updated_at datetime(6) not null,
115+
primary key (notification_id)
116+
) engine=InnoDB;
117+
118+
create table task (
119+
task_id bigint not null auto_increment,
120+
attachment_count integer not null,
121+
description varchar(255),
122+
task_code varchar(255) not null,
123+
title varchar(255) not null,
124+
category_id bigint not null,
125+
task_status enum ('COMPLETED','IN_PROGRESS','IN_REVIEWING','REQUESTED','TERMINATED') not null,
126+
due_date datetime(6),
127+
finished_at datetime(6),
128+
label_id bigint,
129+
processor_id bigint,
130+
processor_order bigint,
131+
requester_id bigint not null,
132+
reviewer_id bigint,
133+
agit_post_id bigint,
134+
is_deleted bit not null,
135+
created_at datetime(6) not null,
136+
updated_at datetime(6) not null,
137+
primary key (task_id)
138+
) engine=InnoDB;
139+
140+
create table task_history (
141+
task_history_id bigint not null auto_increment,
142+
is_deleted bit not null,
143+
comment_id bigint,
144+
modified_member_id bigint,
145+
task_id bigint,
146+
modified_status varchar(255),
147+
type enum ('COMMENT','COMMENT_FILE','PROCESSOR_ASSIGNED','PROCESSOR_CHANGED','STATUS_SWITCHED','TASK_TERMINATED') not null,
148+
created_at datetime(6) not null,
149+
updated_at datetime(6) not null,
150+
primary key (task_history_id)
151+
) engine=InnoDB;
152+
153+
alter table member
154+
add constraint UKmbmcqelty0fbrvxp1q58dn57t unique (email),
155+
add constraint UKhh9kg6jti4n1eoiertn2k6qsc unique (nickname);
156+
alter table task_history
157+
add constraint UK4wh19gakb7pv1u0cseyw1yjmw unique (comment_id);
158+
alter table api_log
159+
add constraint FKftyva6u4tm4iarfrjpbxyf4c9
160+
foreign key (member_id)
161+
references member (member_id);
162+
alter table attachment
163+
add constraint FKliwb3s1jmhbcrq2upsyo2cftn
164+
foreign key (task_id)
165+
references task (task_id);
166+
alter table category
167+
add constraint FKrny90rsn1w2b1ik1on39ucu7f
168+
foreign key (admin_id)
169+
references member (member_id),
170+
add constraint FKtrd7kl5dwdxbvra30i22nrpod
171+
foreign key (main_category_id)
172+
references category (category_id);
173+
alter table comment
174+
add constraint FKmrrrpi513ssu63i2783jyiv9m
175+
foreign key (member_id)
176+
references member (member_id),
177+
add constraint FKfknte4fhjhet3l1802m1yqa50
178+
foreign key (task_id)
179+
references task (task_id);
180+
alter table department
181+
add constraint FKetxumrlg416i5l73fd31axwi1
182+
foreign key (admin_id)
183+
references member (member_id);
184+
alter table label
185+
add constraint FKgoxqkxje84e1jhc8weu7tdkee
186+
foreign key (admin_id)
187+
references member (member_id);
188+
alter table member
189+
add constraint FKai3spm9ctynftc6y5u1ycq7po
190+
foreign key (admin_id)
191+
references member (member_id),
192+
add constraint FKlmd4h7lh9acdyvi0xxbvsqrmk
193+
foreign key (department_id)
194+
references department (department_id);
195+
alter table notification
196+
add constraint FK1jpw68rbaxvu8u5l1dniain1l
197+
foreign key (receiver_id)
198+
references member (member_id),
199+
add constraint FKg6e8dcyvu9qdcfds2o3pj9qen
200+
foreign key (task_id)
201+
references task (task_id);
202+
alter table task
203+
add constraint FKkjb4pwpo8oqc8fvkgbmiitsu9
204+
foreign key (category_id)
205+
references category (category_id),
206+
add constraint FKcvxhsvaa4b0eqvoknwdjoqb8e
207+
foreign key (label_id)
208+
references label (label_id),
209+
add constraint FK7h14q3t26nc05voash0c85a98
210+
foreign key (processor_id)
211+
references member (member_id),
212+
add constraint FKhmhrmkyhc8fnprgehf2tnqgxv
213+
foreign key (requester_id)
214+
references member (member_id),
215+
add constraint FK85w35u60hn4o1mpa8lo9ef2ae
216+
foreign key (reviewer_id)
217+
references member (member_id);
218+
alter table task_history
219+
add constraint FK2ud4b2im20aa3smlseuca0br5
220+
foreign key (comment_id)
221+
references comment (comment_id),
222+
add constraint FK3rh6bjds4lcdwd25ya6dnvxwu
223+
foreign key (modified_member_id)
224+
references member (member_id),
225+
add constraint FKer57q2libi1e9njpj6faoxd2i
226+
foreign key (task_id)
227+
references task (task_id);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CREATE INDEX idx_task_processor_created
2+
ON task (processor_id ASC, created_at DESC);
3+
CREATE INDEX idx_task_requester_created
4+
ON task (requester_id ASC, created_at DESC);
5+
CREATE INDEX idx_task_status_created
6+
ON task (task_status ASC, created_at DESC);
7+
CREATE INDEX idx_task_created
8+
ON task (created_at DESC);

src/main/resources/mysql.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,6 @@ spring:
7171
format_sql: false
7272
show_sql: false
7373
flyway:
74-
enabled: false
75-
baseline-on-migrate: false
74+
enabled: true
75+
baseline-on-migrate: true
7676
locations: classpath:db/migration/prod

0 commit comments

Comments
 (0)