SET @current_schema := DATABASE();

SET @add_sys_badge_display_type_sql := IF(
  NOT EXISTS (
    SELECT 1 FROM information_schema.columns
    WHERE table_schema = @current_schema
      AND table_name = 'sys_badge_config'
      AND column_name = 'display_type'
  ),
  'ALTER TABLE `sys_badge_config` ADD COLUMN `display_type` varchar(16) NOT NULL DEFAULT '''' COMMENT ''展示类型: LONG长徽章 SHORT短徽章'' AFTER `type`',
  'SELECT 1'
);
PREPARE add_sys_badge_display_type_stmt FROM @add_sys_badge_display_type_sql;
EXECUTE add_sys_badge_display_type_stmt;
DEALLOCATE PREPARE add_sys_badge_display_type_stmt;

UPDATE `sys_badge_config`
SET `display_type` = 'LONG'
WHERE `type` = 'VIP'
  AND (`display_type` IS NULL OR `display_type` = '');

UPDATE `sys_badge_config`
SET `display_type` = 'SHORT'
WHERE `type` <> 'VIP'
  AND (`display_type` IS NULL OR `display_type` = '');
