diff --git a/contact-center/config/sql/upgrade/001.alter_uk_consult_invite.sql b/contact-center/config/sql/upgrade/001.alter_uk_consult_invite.sql index 06f8cf37..4948eb3f 100644 --- a/contact-center/config/sql/upgrade/001.alter_uk_consult_invite.sql +++ b/contact-center/config/sql/upgrade/001.alter_uk_consult_invite.sql @@ -1,3 +1,32 @@ --- Enable whitelist for online users USE `cosinee`; -ALTER TABLE uk_consult_invite add whitelist_mode tinyint(4) DEFAULT '0' COMMENT '启用白名单'; \ No newline at end of file +-- ----------------- +-- prepare variables +-- ----------------- + +SET @dbname = DATABASE ( ); +SET @tablename = "uk_consult_invite"; +SET @columnname = "whitelist_mode"; + +SET @preparedStatement = ( + SELECT + IF + ( + ( + SELECT + COUNT( * ) + FROM + INFORMATION_SCHEMA.COLUMNS + WHERE + ( table_name = @tablename ) + AND ( table_schema = @dbname ) + AND ( column_name = @columnname ) + ) > 0, + "SELECT 1", + CONCAT( "ALTER TABLE ", @tablename, " ADD ", @columnname, " TINYINT ( 4 ) DEFAULT '0' COMMENT '启用白名单';" ) + ) +); +PREPARE alterIfNotExists +FROM + @preparedStatement; +EXECUTE alterIfNotExists; +DEALLOCATE PREPARE alterIfNotExists; \ No newline at end of file