Skip to content

Commit 69fec77

Browse files
committed
Merge remote-tracking branch 'origin/develop' into develop
2 parents 05d7a17 + 571afa4 commit 69fec77

5 files changed

Lines changed: 751 additions & 44 deletions

File tree

build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ plugins {
22
id 'java'
33
id 'org.springframework.boot' version '3.5.0'
44
id 'io.spring.dependency-management' version '1.1.7'
5+
id 'org.flywaydb.flyway' version '10.14.0'
56
}
67

78
group = 'bitnagil'
@@ -62,6 +63,10 @@ dependencies {
6263

6364
// aws
6465
implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'
66+
67+
// flyway
68+
implementation 'org.flywaydb:flyway-core'
69+
implementation 'org.flywaydb:flyway-mysql'
6570
}
6671

6772
tasks.named('test') {
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
-- 기존 운영 DB에 반영된 테이블 구조
2+
create table changed_routine
3+
(
4+
changed_execution_time time(6) not null,
5+
changed_routine_date date not null,
6+
original_routine_date date not null,
7+
created_at timestamp not null,
8+
deleted_at datetime(6) null,
9+
history_end_date_time datetime(6) not null,
10+
history_seq bigint not null,
11+
history_start_date_time datetime(6) not null,
12+
updated_at timestamp null,
13+
changed_routine_id binary(16) not null,
14+
routine_id binary(16) null,
15+
user_id binary(16) not null,
16+
changed_routine_name varchar(255) not null,
17+
changed_div_code varchar(40) null,
18+
primary key (history_seq, changed_routine_id)
19+
);
20+
21+
create table changed_sub_routine
22+
(
23+
sort_order int not null,
24+
created_at timestamp not null,
25+
deleted_at datetime(6) null,
26+
history_end_date_time datetime(6) not null,
27+
history_seq bigint not null,
28+
history_start_date_time datetime(6) not null,
29+
updated_at timestamp null,
30+
changed_routine_id binary(16) not null,
31+
changed_sub_routine_id binary(16) not null,
32+
changed_sub_routine_name varchar(255) not null,
33+
primary key (history_seq, changed_sub_routine_id)
34+
);
35+
36+
create table emotion_marble
37+
(
38+
date date not null,
39+
case_id bigint not null,
40+
created_at timestamp not null,
41+
deleted_at datetime(6) null,
42+
history_end_date_time datetime(6) not null,
43+
history_seq bigint not null,
44+
history_start_date_time datetime(6) not null,
45+
updated_at timestamp null,
46+
emotion_marble_id binary(16) not null,
47+
user_id binary(16) not null,
48+
emotion_marble_type varchar(40) not null,
49+
primary key (history_seq, emotion_marble_id)
50+
);
51+
52+
create table onboarding
53+
(
54+
time_slot time(6) not null,
55+
case_id bigint not null,
56+
created_at timestamp not null,
57+
deleted_at datetime(6) null,
58+
onboarding_id bigint auto_increment
59+
primary key,
60+
updated_at timestamp null,
61+
emotion_type varchar(40) not null,
62+
real_outing_frequency varchar(40) not null,
63+
target_outing_frequency varchar(40) not null
64+
);
65+
66+
create table recommended_routine
67+
(
68+
execution_time time(6) null,
69+
case_id bigint null,
70+
created_at timestamp not null,
71+
deleted_at datetime(6) null,
72+
recommended_routine_id bigint auto_increment
73+
primary key,
74+
updated_at timestamp null,
75+
recommended_routine_description varchar(255) null,
76+
recommended_routine_name varchar(255) null,
77+
thumbnail_url varchar(255) null,
78+
emotion varchar(40) null,
79+
recommended_routine_level varchar(40) null,
80+
recommended_routine_type varchar(40) null
81+
);
82+
83+
create table recommended_sub_routine
84+
(
85+
created_at timestamp not null,
86+
deleted_at datetime(6) null,
87+
recommended_routine_id bigint null,
88+
recommended_sub_routine_id bigint auto_increment
89+
primary key,
90+
updated_at timestamp null,
91+
sub_routine_name varchar(255) null
92+
);
93+
94+
create table routine
95+
(
96+
execution_time time(6) not null,
97+
created_at timestamp not null,
98+
deleted_at datetime(6) null,
99+
history_end_date_time datetime(6) not null,
100+
history_seq bigint not null,
101+
history_start_date_time datetime(6) not null,
102+
updated_at timestamp null,
103+
routine_id binary(16) not null,
104+
user_id binary(16) not null,
105+
name varchar(255) not null,
106+
repeat_day varchar(255) not null,
107+
primary key (history_seq, routine_id)
108+
);
109+
110+
create table routine_case
111+
(
112+
case_id bigint auto_increment
113+
primary key,
114+
created_at timestamp not null,
115+
deleted_at datetime(6) null,
116+
updated_at timestamp null
117+
);
118+
119+
create table routine_completion
120+
(
121+
complete_yn bit not null,
122+
performed_date date not null,
123+
created_at timestamp not null,
124+
deleted_at datetime(6) null,
125+
routine_completion_id bigint auto_increment
126+
primary key,
127+
routine_history_seq bigint not null,
128+
updated_at timestamp null,
129+
routine_id binary(16) not null,
130+
routine_type varchar(40) not null
131+
);
132+
133+
create table sub_routine
134+
(
135+
sort_order int not null,
136+
created_at timestamp not null,
137+
deleted_at datetime(6) null,
138+
history_end_date_time datetime(6) not null,
139+
history_seq bigint not null,
140+
history_start_date_time datetime(6) not null,
141+
updated_at timestamp null,
142+
routine_id binary(16) not null,
143+
sub_routine_id binary(16) not null,
144+
name varchar(255) not null,
145+
primary key (history_seq, sub_routine_id)
146+
);
147+
148+
create table user
149+
(
150+
agreed_to_privacy_policy bit null,
151+
agreed_to_terms_of_service bit null,
152+
is_over_fourteen bit null,
153+
created_at timestamp not null,
154+
deleted_at datetime(6) null,
155+
history_end_date_time datetime(6) not null,
156+
history_seq bigint not null,
157+
history_start_date_time datetime(6) not null,
158+
onboarding_id bigint null,
159+
updated_at timestamp null,
160+
user_id binary(16) not null,
161+
email varchar(255) not null,
162+
nickname varchar(255) not null,
163+
refresh_token varchar(255) null,
164+
social_id varchar(255) not null,
165+
role varchar(40) not null,
166+
social_type varchar(40) null,
167+
primary key (history_seq, user_id)
168+
);
169+
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
-- emotion marble 테이블 백업
2+
RENAME TABLE emotion_marble TO emotion_marble_old;
3+
4+
-- 새로운 emotion_marble 테이블 생성(이력 테이블에서 일반 테이블로 재구성. UUID 제거, history_seq 제거, PK 변경)
5+
CREATE TABLE emotion_marble (
6+
date DATE NOT NULL,
7+
case_id BIGINT NOT NULL,
8+
created_at TIMESTAMP NOT NULL,
9+
deleted_at DATETIME(6),
10+
emotion_marble_id BIGINT NOT NULL AUTO_INCREMENT,
11+
history_end_date_time DATETIME(6) NOT NULL,
12+
history_start_date_time DATETIME(6) NOT NULL,
13+
updated_at TIMESTAMP NULL,
14+
user_id BIGINT NOT NULL,
15+
emotion_marble_type VARCHAR(40) NOT NULL,
16+
PRIMARY KEY (emotion_marble_id)
17+
);
18+
19+
20+
-- routine 테이블 백업
21+
RENAME TABLE routine TO routine_old;
22+
23+
-- 새로운 routine 테이블 생성(user_id를 UUID에서 BIGINT로 변경)
24+
create table routine (
25+
execution_time time(6) not null,
26+
created_at TIMESTAMP not null,
27+
deleted_at datetime(6),
28+
history_end_date_time datetime(6) not null,
29+
history_seq bigint not null,
30+
history_start_date_time datetime(6) not null,
31+
updated_at TIMESTAMP null,
32+
user_id bigint not null,
33+
routine_id binary(16) not null,
34+
name varchar(255) not null,
35+
repeat_day varchar(255) not null,
36+
primary key (history_seq, routine_id)
37+
);
38+
39+
-- v2를 위한 routine_infov2 생성
40+
create table routine_infov2 (
41+
routine_end_date date not null,
42+
routine_execution_time time(6) not null,
43+
routine_start_date date not null,
44+
routine_info_id bigint not null auto_increment,
45+
user_id bigint,
46+
routine_name varchar(255) not null,
47+
routine_repeat_day varchar(255) not null,
48+
primary key (routine_info_id)
49+
);
50+
51+
-- v2를 위한 routinev2 생성
52+
create table routinev2 (
53+
routine_complete_yn bit not null,
54+
routine_date date not null,
55+
routine_id bigint not null auto_increment,
56+
routine_info_id bigint,
57+
sub_routine_complete_yn varchar(255) not null,
58+
sub_routine_names varchar(255) not null,
59+
primary key (routine_id)
60+
);
61+
62+
-- user 테이블 백업
63+
RENAME TABLE user TO user_old;
64+
65+
-- 새로운 user 테이블 생성(이력 테이블에서 일반 테이블로 재구성. UUID 제거, history_seq 제거, PK 변경)
66+
create table user (
67+
agreed_to_privacy_policy bit,
68+
agreed_to_terms_of_service bit,
69+
is_over_fourteen bit,
70+
created_at TIMESTAMP not null,
71+
deleted_at datetime(6),
72+
onboarding_id bigint,
73+
updated_at TIMESTAMP null,
74+
user_id bigint not null auto_increment,
75+
email varchar(255) not null,
76+
nickname varchar(255) not null,
77+
refresh_token varchar(255),
78+
social_id varchar(255) not null,
79+
role varchar(40) not null,
80+
social_type varchar(40),
81+
primary key (user_id)
82+
);
83+
84+
85+
alter table emotion_marble
86+
add constraint FKte7yhv7ov29ugokq957g5qmmk
87+
foreign key (case_id)
88+
references routine_case (case_id);
89+
90+
alter table onboarding
91+
add constraint FKfc8jstk9agqu5j9qj490gr2jj
92+
foreign key (case_id)
93+
references routine_case (case_id);
94+
95+
alter table recommended_routine
96+
add constraint FKt4eirwywowa6an7qkimt3df6n
97+
foreign key (case_id)
98+
references routine_case (case_id);
99+
100+
alter table recommended_sub_routine
101+
add constraint FKp7i2oxf4pgrqjr1u91otkpkhl
102+
foreign key (recommended_routine_id)
103+
references recommended_routine (recommended_routine_id);
104+
105+
alter table routine_infov2
106+
add constraint FKn1lmdefo4tyu868b8d3x0m3c0
107+
foreign key (user_id)
108+
references user (user_id);
109+
110+
alter table routinev2
111+
add constraint FKomkes8k4o9ad92pj05nyd8w6e
112+
foreign key (routine_info_id)
113+
references routine_infov2 (routine_info_id);
114+
115+
alter table user
116+
add constraint FKgyq5wxekqb3h4n9i9ilfuro5v
117+
foreign key (onboarding_id)
118+
references onboarding (onboarding_id);

0 commit comments

Comments
 (0)