Skip to content

Commit f1b10a8

Browse files
authored
Merge pull request #131 from Pocket-PT/develop
[Release] 1차 배포 - flyway 도입, chatting-message-bookmark 수정
2 parents f8f994d + 982a2f0 commit f1b10a8

File tree

8 files changed

+286
-6
lines changed

8 files changed

+286
-6
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ out/
4848
pocketpt/local.properties
4949

5050
### DB volumes ###
51-
db
51+
#db
5252

5353
### Mac ###
5454
.DS_Store

pocketpt/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ dependencies {
3636
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
3737

3838
// flyway 데이터베이스 마이그레이션 도구
39-
// implementation 'org.flywaydb:flyway-mysql'
39+
implementation 'org.flywaydb:flyway-mysql'
4040

4141
implementation 'org.webjars:stomp-websocket:2.3.4'
4242
implementation 'org.webjars:webjars-locator-core'

pocketpt/src/main/java/com/madeyepeople/pocketpt/domain/chattingMessage/repository/ChattingMessageRepository.java

+12-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public interface ChattingMessageRepository extends JpaRepository<ChattingMessage
2525
""", nativeQuery = true)
2626
Optional<ChattingMessage> findLatestChattingMessageByRoom(Long chattingRoom);
2727

28-
// 삭제되지 않은 메시지
28+
// 삭제되지 않은 나의 메시지
2929
@Query(value=
3030
"""
3131
SELECT *
@@ -37,6 +37,17 @@ public interface ChattingMessageRepository extends JpaRepository<ChattingMessage
3737
""", nativeQuery = true)
3838
Optional<ChattingMessage> findByIdAndRoomIdAndAccountIdAndIsDeletedFalse(Long chattingRoom, Long account, Long chattingMessage);
3939

40+
// 삭제되지 않은 메시지
41+
@Query(value=
42+
"""
43+
SELECT *
44+
FROM chatting_message m
45+
WHERE m.chatting_room = :chattingRoom
46+
AND m.chatting_message_id = :chattingMessage
47+
AND is_deleted = FALSE
48+
""", nativeQuery = true)
49+
Optional<ChattingMessage> findByIdAndRoomIdAndIsDeletedFalse(Long chattingRoom, Long chattingMessage);
50+
4051
// 채팅방의 메시지 총개수
4152
@Query(value =
4253
"""

pocketpt/src/main/java/com/madeyepeople/pocketpt/domain/chattingMessageBookmark/service/ChattingMessageBookmarkService.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public ResultResponse createChattingMessageBookmark(Long roomId, Long accountId,
6464
);
6565

6666
// [3] 메시지 유효성 검사
67-
ChattingMessage chattingMessage = chattingMessageRepository.findByIdAndRoomIdAndAccountIdAndIsDeletedFalse(roomId, accountId, chattingMessageId).orElseThrow(
67+
ChattingMessage chattingMessage = chattingMessageRepository.findByIdAndRoomIdAndIsDeletedFalse(roomId, chattingMessageId).orElseThrow(
6868
() -> new BusinessException(ErrorCode.CHATTING_MESSAGE_NOT_FOUND, CustomExceptionMessage.CHATTING_MESSAGE_NOT_FOUND.getMessage())
6969
);
7070

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.madeyepeople.pocketpt.global.config;
2+
3+
import org.springframework.boot.autoconfigure.flyway.FlywayMigrationStrategy;
4+
import org.springframework.context.annotation.Bean;
5+
import org.springframework.context.annotation.Configuration;
6+
7+
@Configuration
8+
public class FlywayConfig {
9+
10+
@Bean
11+
public FlywayMigrationStrategy cleanMigrateStrategy() {
12+
return flyway -> {
13+
flyway.repair();
14+
flyway.migrate();
15+
};
16+
}
17+
}

pocketpt/src/main/resources/application-dev.yml

+7-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@ spring:
1616
password: ${SPRING_DATASOURCE_PASSWORD}
1717
driver-class-name: com.mysql.cj.jdbc.Driver
1818

19-
# flyway:
20-
# baseline-on-migrate: true
19+
flyway:
20+
enabled: true
21+
baseline-on-migrate: true
22+
url: ${SPRING_DATASOURCE_URL}
23+
user: ${SPRING_DATASOURCE_USERNAME}
24+
password: ${SPRING_DATASOURCE_PASSWORD}
25+
locations: classpath:db/migration
2126

2227
jpa:
2328
database: mysql

pocketpt/src/main/resources/application-prod.yml

+8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ spring:
1313
password: ${SPRING_DATASOURCE_PASSWORD}
1414
driver-class-name: com.mysql.cj.jdbc.Driver
1515

16+
flyway:
17+
enabled: true
18+
baseline-on-migrate: true
19+
url: ${SPRING_DATASOURCE_URL}
20+
user: ${SPRING_DATASOURCE_USERNAME}
21+
password: ${SPRING_DATASOURCE_PASSWORD}
22+
locations: classpath:db/migration
23+
1624
jpa:
1725
database: mysql
1826
# defer-datasource-initialization: true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
create table account (
2+
discount_rate float(23),
3+
height float(23),
4+
is_deleted boolean default false not null,
5+
service_fee_rate float(23),
6+
total_sales integer default 0,
7+
weight float(23),
8+
account_id bigint not null auto_increment,
9+
birthdate datetime(6),
10+
created_at datetime(6),
11+
oauth2_id bigint,
12+
updated_at datetime(6),
13+
account_role varchar(255),
14+
career_certificate_url varchar(255),
15+
email varchar(255),
16+
expertise varchar(255),
17+
gender varchar(255),
18+
identification_code varchar(255),
19+
introduce varchar(255),
20+
name varchar(255),
21+
nickname varchar(255),
22+
oauth_access_token varchar(255),
23+
password varchar(255),
24+
phone_number varchar(255),
25+
profile_picture_url varchar(255),
26+
provider varchar(255),
27+
recommender_code varchar(255),
28+
primary key (account_id)
29+
) engine=InnoDB
30+
31+
create table career (
32+
is_deleted boolean default false not null,
33+
account_id bigint,
34+
career_id bigint not null auto_increment,
35+
created_at datetime(6),
36+
updated_at datetime(6),
37+
date varchar(255),
38+
title varchar(255),
39+
type varchar(255),
40+
primary key (career_id)
41+
) engine=InnoDB
42+
43+
create table chatting_message (
44+
is_deleted boolean default false not null,
45+
is_edited bit not null,
46+
not_view_count integer not null,
47+
account bigint,
48+
chatting_message_id bigint not null auto_increment,
49+
chatting_room bigint,
50+
created_at datetime(6),
51+
updated_at datetime(6),
52+
content varchar(255),
53+
file_url TEXT,
54+
primary key (chatting_message_id)
55+
) engine=InnoDB
56+
57+
create table chatting_message_bookmark (
58+
is_deleted boolean default false not null,
59+
account_id bigint not null,
60+
chatting_message_id bigint not null,
61+
chatting_room_id bigint not null,
62+
created_at datetime(6),
63+
updated_at datetime(6),
64+
primary key (account_id, chatting_message_id, chatting_room_id)
65+
) engine=InnoDB
66+
67+
create table chatting_participant (
68+
is_deleted boolean default false not null,
69+
is_host bit not null,
70+
not_view_count integer not null,
71+
account_id bigint not null,
72+
chatting_room_entry_time datetime(6),
73+
chatting_room_exit_time datetime(6),
74+
chatting_room_id bigint not null,
75+
created_at datetime(6),
76+
updated_at datetime(6),
77+
simp_session_id varchar(255),
78+
primary key (account_id, chatting_room_id)
79+
) engine=InnoDB
80+
81+
create table chatting_room (
82+
is_deleted boolean default false not null,
83+
number_of_participant integer not null,
84+
status tinyint not null,
85+
chatting_room_id bigint not null auto_increment,
86+
created_at datetime(6),
87+
host_id bigint not null,
88+
updated_at datetime(6),
89+
room_name varchar(255),
90+
primary key (chatting_room_id)
91+
) engine=InnoDB
92+
93+
create table historical_data (
94+
is_deleted boolean default false not null,
95+
account_id bigint not null,
96+
created_at datetime(6),
97+
date datetime(6),
98+
historical_data_id bigint not null auto_increment,
99+
updated_at datetime(6),
100+
description varchar(255),
101+
scope varchar(255),
102+
title varchar(255),
103+
primary key (historical_data_id)
104+
) engine=InnoDB
105+
106+
create table historical_data_file (
107+
is_deleted boolean default false not null,
108+
created_at datetime(6),
109+
historical_data_file_id bigint not null auto_increment,
110+
historical_data_id bigint not null,
111+
updated_at datetime(6),
112+
file_url varchar(255),
113+
scope varchar(255),
114+
primary key (historical_data_file_id)
115+
) engine=InnoDB
116+
117+
create table monthly_pt_price (
118+
is_deleted boolean default false not null,
119+
period integer,
120+
price integer,
121+
account_id bigint,
122+
created_at datetime(6),
123+
monthly_pt_price_id bigint not null auto_increment,
124+
updated_at datetime(6),
125+
primary key (monthly_pt_price_id)
126+
) engine=InnoDB
127+
128+
create table pt_matching (
129+
is_deleted boolean default false not null,
130+
is_new_subscription bit,
131+
payment_amount integer,
132+
subscription_period integer,
133+
created_at datetime(6),
134+
expired_date datetime(6),
135+
pt_matching_id bigint not null auto_increment,
136+
start_date datetime(6),
137+
trainee_account_id bigint,
138+
trainer_account_id bigint,
139+
updated_at datetime(6),
140+
contact_type varchar(255),
141+
precaution varchar(255),
142+
reject_reason varchar(255),
143+
status varchar(255),
144+
primary key (pt_matching_id)
145+
) engine=InnoDB
146+
147+
create table purpose (
148+
is_deleted boolean default false not null,
149+
target_date date,
150+
account_id bigint,
151+
created_at datetime(6),
152+
purpose_id bigint not null auto_increment,
153+
updated_at datetime(6),
154+
content varchar(255),
155+
title varchar(255),
156+
primary key (purpose_id)
157+
) engine=InnoDB
158+
159+
create table top_chatting_room (
160+
is_deleted boolean default false not null,
161+
account_id bigint not null,
162+
chatting_room_id bigint not null,
163+
created_at datetime(6),
164+
updated_at datetime(6),
165+
primary key (account_id, chatting_room_id)
166+
) engine=InnoDB
167+
168+
alter table account
169+
add constraint UK_83mc3wdw5cs7otc48exl2g9oa unique (identification_code)
170+
171+
alter table career
172+
add constraint FKjsolsxeh4qap0ga7sidb5ol70
173+
foreign key (account_id)
174+
references account (account_id)
175+
176+
alter table chatting_message_bookmark
177+
add constraint FK401m1640clwl9coknhu8utwms
178+
foreign key (account_id)
179+
references account (account_id)
180+
181+
alter table chatting_message_bookmark
182+
add constraint FK2xr546hkhv3nt4tvm8qx9ais9
183+
foreign key (chatting_message_id)
184+
references chatting_message (chatting_message_id)
185+
186+
alter table chatting_message_bookmark
187+
add constraint FKf2pp5gljs27gb65ry9g5cn8as
188+
foreign key (chatting_room_id)
189+
references chatting_room (chatting_room_id)
190+
191+
alter table chatting_participant
192+
add constraint FKo72wxi8iuobqia3ib16l7wngw
193+
foreign key (account_id)
194+
references account (account_id)
195+
196+
alter table chatting_participant
197+
add constraint FK7qrx8qm8j9udnlvryi0obyy02
198+
foreign key (chatting_room_id)
199+
references chatting_room (chatting_room_id)
200+
201+
alter table historical_data
202+
add constraint FKa9y3h19bvcclpixx3ogr3c7nb
203+
foreign key (account_id)
204+
references account (account_id)
205+
206+
alter table historical_data_file
207+
add constraint FKeara218058068op1wpf8err2t
208+
foreign key (historical_data_id)
209+
references historical_data (historical_data_id)
210+
211+
alter table monthly_pt_price
212+
add constraint FKlgvwurtxja3r9bsxf5b9bflwd
213+
foreign key (account_id)
214+
references account (account_id)
215+
216+
alter table pt_matching
217+
add constraint FK2uqsyc1k5sfhxs2wekbqppmgg
218+
foreign key (trainee_account_id)
219+
references account (account_id)
220+
221+
alter table pt_matching
222+
add constraint FKeohpalxemt7bjhd7jurrxprxi
223+
foreign key (trainer_account_id)
224+
references account (account_id)
225+
226+
alter table purpose
227+
add constraint FKj3p0cuhk14r0u44okaiyqdw7g
228+
foreign key (account_id)
229+
references account (account_id)
230+
231+
alter table top_chatting_room
232+
add constraint FKnvm80wb2hv5eed2f5soafe73q
233+
foreign key (account_id)
234+
references account (account_id)
235+
236+
alter table top_chatting_room
237+
add constraint FK50uww0n32n3cce3myx4g27lib
238+
foreign key (chatting_room_id)
239+
references chatting_room (chatting_room_id)

0 commit comments

Comments
 (0)