-
Notifications
You must be signed in to change notification settings - Fork 0
fix/#150: 네컷사진 삭제 시 Soft Delete 로 변경 #151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/main/resources/db/migration/V12__add_soft_delete_to_photo_image.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| -- deleted_at 컬럼 추가 (soft delete용) | ||
| ALTER TABLE TB_PHOTO_IMAGE ADD COLUMN deleted_at TIMESTAMP NULL; | ||
|
|
||
| -- 기존 unique constraint 제거 | ||
| -- soft-deleted 레코드까지 포함하면 삭제 후 같은 미디어 재등록 시 unique violation 발생 | ||
| ALTER TABLE TB_PHOTO_IMAGE DROP CONSTRAINT uk_photo_image_media_id; | ||
|
|
||
| -- Partial Unique Index로 교체 (deleted_at IS NULL인 레코드에만 unique 보장) | ||
| CREATE UNIQUE INDEX uk_photo_image_media_id | ||
| ON TB_PHOTO_IMAGE (media_id) | ||
| WHERE deleted_at IS NULL; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QueryDSL의
update쿼리는 Hibernate의@SQLRestriction필터를 자동으로 적용하지 않으므로, 여기서deletedAt.isNull조건을 명시적으로 추가하신 것은 매우 적절합니다. 다만,folderId가null로 변경되는 Soft Delete 특성상photoImage.folderId.in(folderIds)조건만으로도 이미 삭제된 데이터는 제외될 것으로 보입니다. 하지만 안전성을 위해 유지하는 것도 나쁘지 않습니다.