Skip to content

Commit cfbd3fd

Browse files
committed
CLAP-375 Fix: comment 테이블 속성 flyway 스키마에 추가
1 parent da2eb01 commit cfbd3fd

3 files changed

Lines changed: 23 additions & 6 deletions

File tree

src/main/java/clap/server/adapter/outbound/persistense/entity/task/AttachmentEntity.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ public class AttachmentEntity extends BaseTimeEntity {
3535
@JoinColumn(name = "task_id")
3636
private TaskEntity task;
3737

38-
// @OneToOne(fetch = FetchType.LAZY)
39-
// @JoinColumn(name = "comment_id")
40-
// private CommentEntity comment;
41-
4238
@Column(name= "is_deleted", nullable = false)
4339
@Builder.Default
4440
private boolean isDeleted = Boolean.FALSE;

src/main/java/clap/server/application/service/history/PostCommentService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public void saveCommentAttachment(Long memberId, Long taskId, MultipartFile file
7373
taskCommentPolicy.validateCommentPermission(task, member);
7474
Comment comment = Comment.createComment(member, task, null);
7575
Comment savedComment = commandCommentPort.saveComment(comment);
76-
String fileName = saveAttachment(file, task, savedComment);
76+
String fileName = saveAttachment(file, task);
7777

7878
TaskHistory taskHistory = TaskHistory.createTaskHistory(TaskHistoryType.COMMENT_FILE, task, null, member, savedComment);
7979
commandTaskHistoryPort.save(taskHistory);
@@ -88,7 +88,7 @@ public void saveCommentAttachment(Long memberId, Long taskId, MultipartFile file
8888

8989
}
9090

91-
private String saveAttachment(MultipartFile file, Task task, Comment comment) {
91+
private String saveAttachment(MultipartFile file, Task task) {
9292
String fileUrl = s3UploadPort.uploadSingleFile(FilePathConstants.TASK_COMMENT, file);
9393
Attachment attachment = Attachment.createCommentAttachment(task, file.getOriginalFilename(), fileUrl, file.getSize());
9494
commandAttachmentPort.save(attachment);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
-- Step 1: comment 테이블에 컬럼 추가
2+
ALTER TABLE comment
3+
ADD COLUMN original_name VARCHAR(255),
4+
ADD COLUMN file_url VARCHAR(255),
5+
ADD COLUMN file_size VARCHAR(255);
6+
7+
-- Step 2: attachment 데이터 복사
8+
START TRANSACTION;
9+
UPDATE comment c
10+
JOIN attachment a ON c.comment_id = a.comment_id
11+
SET
12+
c.original_name = a.original_name,
13+
c.file_url = a.file_url,
14+
c.file_size = a.file_size,
15+
WHERE c.attachment_id IS NOT NULL;
16+
COMMIT;
17+
18+
-- Step 3: attachment 테이블에 제약조건 제거
19+
ALTER TABLE attachment
20+
DROP FOREIGN KEY FKds6u1rptrsif835t89kb15cyo,
21+
DROP COLUMN comment_id;

0 commit comments

Comments
 (0)