-
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.
Browse files
Browse the repository at this point in the history
#127 enhance hotopentalk
- Loading branch information
Showing
7 changed files
with
373 additions
and
320 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
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/V2__Add_column_to_book.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 @@ | ||
-- bookname 컬럼 추가 | ||
SET @col_exists_bookname = ( | ||
SELECT COUNT(*) | ||
FROM INFORMATION_SCHEMA.COLUMNS | ||
WHERE TABLE_NAME = 'book' AND COLUMN_NAME = 'bookname' | ||
); | ||
|
||
SET @sql_bookname = IF(@col_exists_bookname = 0, 'ALTER TABLE book ADD COLUMN bookname VARCHAR(255);', 'SELECT "bookname column already exists";'); | ||
PREPARE stmt_bookname FROM @sql_bookname; | ||
EXECUTE stmt_bookname; | ||
DEALLOCATE PREPARE stmt_bookname; | ||
|
||
-- book_imageurl 컬럼 추가 | ||
SET @col_exists_book_imageurl = ( | ||
SELECT COUNT(*) | ||
FROM INFORMATION_SCHEMA.COLUMNS | ||
WHERE TABLE_NAME = 'book' AND COLUMN_NAME = 'book_imageurl' | ||
); | ||
|
||
SET @sql_book_imageurl = IF(@col_exists_book_imageurl = 0, 'ALTER TABLE book ADD COLUMN book_imageurl VARCHAR(255);', 'SELECT "book_imageurl column already exists";'); | ||
PREPARE stmt_book_imageurl FROM @sql_book_imageurl; | ||
EXECUTE stmt_book_imageurl; | ||
DEALLOCATE PREPARE stmt_book_imageurl; | ||
|
||
|
||
/* 특정 테이블 칼럼 삭제 | ||
-- 1. 컬럼 존재 여부 확인 | ||
SELECT COUNT(*) INTO @col_exists | ||
FROM INFORMATION_SCHEMA.COLUMNS | ||
WHERE TABLE_NAME = 'book' AND COLUMN_NAME = 'bookname'; | ||
-- 2. 컬럼 삭제 | ||
SET @sql = IF(@col_exists > 0, 'ALTER TABLE book DROP COLUMN bookname;', 'SELECT "Column does not exist";'); | ||
PREPARE stmt FROM @sql; | ||
EXECUTE stmt; | ||
DEALLOCATE PREPARE stmt; | ||
*/ |
Oops, something went wrong.