-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #149 from Media-XI/ART-168-be-매거진-콘텐츠에-미디어-url-첨부
매거진 콘텐츠에 미디어 URL 첨부 프로시저 작성
- Loading branch information
Showing
5 changed files
with
42 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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 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 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
37 changes: 37 additions & 0 deletions
37
src/main/resources/db/migration/V202403051151__application.sql
This file contains 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,37 @@ | ||
|
||
# 매거진 콘텐츠 맨 앞에 마크다운 형식의 미디어 URL 을 첨부합니다. | ||
# 작성자 : Hoon9901 (shonn.dev@gmail.com) | ||
# 작성 날짜 : 2024-03-18 | ||
# 현재 버전 : V202403051151 (이전 버전 : V202403051150__create_curation_table.sql) | ||
|
||
DELIMITER $$ | ||
CREATE PROCEDURE add_first_media_to_content() | ||
BEGIN | ||
DECLARE done BOOLEAN DEFAULT FALSE; | ||
DECLARE p_magazine_id INT; | ||
DECLARE cur CURSOR FOR | ||
SELECT m.magazine_id | ||
FROM magazine m | ||
INNER JOIN magazine_media mm ON (m.magazine_id = mm.magazine_id); | ||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE; # NOT FOUND -> done true | ||
START TRANSACTION; | ||
OPEN cur; | ||
l:LOOP | ||
FETCH cur INTO p_magazine_id; | ||
IF done THEN | ||
LEAVE l; | ||
END IF; | ||
UPDATE magazine m | ||
SET content = CONCAT((SELECT CONCAT('![](https://cdn.artscope.kr/', mm.url, ')') | ||
FROM magazine_media mm | ||
WHERE mm.magazine_id = p_magazine_id | ||
LIMIT 1), ' ', content) | ||
WHERE m.magazine_id = p_magazine_id; | ||
END LOOP; | ||
CLOSE cur; | ||
COMMIT; | ||
END$$ | ||
DELIMITER ; | ||
|
||
CALL add_first_media_to_content(); | ||
DROP PROCEDURE add_first_media_to_content; |
This file contains 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