SET @current_schema := DATABASE();

SET @add_vip_level_short_badge_resource_id_sql := IF(
  NOT EXISTS (
    SELECT 1 FROM information_schema.columns
    WHERE table_schema = @current_schema
      AND table_name = 'vip_level_config'
      AND column_name = 'short_badge_resource_id'
  ),
  'ALTER TABLE `vip_level_config` ADD COLUMN `short_badge_resource_id` bigint NOT NULL DEFAULT 0 COMMENT ''短徽章资源ID'' AFTER `badge_url`',
  'SELECT 1'
);
PREPARE add_vip_level_short_badge_resource_id_stmt FROM @add_vip_level_short_badge_resource_id_sql;
EXECUTE add_vip_level_short_badge_resource_id_stmt;
DEALLOCATE PREPARE add_vip_level_short_badge_resource_id_stmt;

SET @add_vip_level_short_badge_name_sql := IF(
  NOT EXISTS (
    SELECT 1 FROM information_schema.columns
    WHERE table_schema = @current_schema
      AND table_name = 'vip_level_config'
      AND column_name = 'short_badge_name'
  ),
  'ALTER TABLE `vip_level_config` ADD COLUMN `short_badge_name` varchar(128) NOT NULL DEFAULT '''' COMMENT ''短徽章名称'' AFTER `short_badge_resource_id`',
  'SELECT 1'
);
PREPARE add_vip_level_short_badge_name_stmt FROM @add_vip_level_short_badge_name_sql;
EXECUTE add_vip_level_short_badge_name_stmt;
DEALLOCATE PREPARE add_vip_level_short_badge_name_stmt;

SET @add_vip_level_short_badge_url_sql := IF(
  NOT EXISTS (
    SELECT 1 FROM information_schema.columns
    WHERE table_schema = @current_schema
      AND table_name = 'vip_level_config'
      AND column_name = 'short_badge_url'
  ),
  'ALTER TABLE `vip_level_config` ADD COLUMN `short_badge_url` varchar(512) NOT NULL DEFAULT '''' COMMENT ''短徽章资源URL'' AFTER `short_badge_name`',
  'SELECT 1'
);
PREPARE add_vip_level_short_badge_url_stmt FROM @add_vip_level_short_badge_url_sql;
EXECUTE add_vip_level_short_badge_url_stmt;
DEALLOCATE PREPARE add_vip_level_short_badge_url_stmt;

SET @add_vip_level_background_card_resource_id_sql := IF(
  NOT EXISTS (
    SELECT 1 FROM information_schema.columns
    WHERE table_schema = @current_schema
      AND table_name = 'vip_level_config'
      AND column_name = 'background_card_resource_id'
  ),
  'ALTER TABLE `vip_level_config` ADD COLUMN `background_card_resource_id` bigint NOT NULL DEFAULT 0 COMMENT ''背景卡资源ID'' AFTER `float_picture_url`',
  'SELECT 1'
);
PREPARE add_vip_level_background_card_resource_id_stmt FROM @add_vip_level_background_card_resource_id_sql;
EXECUTE add_vip_level_background_card_resource_id_stmt;
DEALLOCATE PREPARE add_vip_level_background_card_resource_id_stmt;

SET @add_vip_level_background_card_name_sql := IF(
  NOT EXISTS (
    SELECT 1 FROM information_schema.columns
    WHERE table_schema = @current_schema
      AND table_name = 'vip_level_config'
      AND column_name = 'background_card_name'
  ),
  'ALTER TABLE `vip_level_config` ADD COLUMN `background_card_name` varchar(128) NOT NULL DEFAULT '''' COMMENT ''背景卡名称'' AFTER `background_card_resource_id`',
  'SELECT 1'
);
PREPARE add_vip_level_background_card_name_stmt FROM @add_vip_level_background_card_name_sql;
EXECUTE add_vip_level_background_card_name_stmt;
DEALLOCATE PREPARE add_vip_level_background_card_name_stmt;

SET @add_vip_level_background_card_url_sql := IF(
  NOT EXISTS (
    SELECT 1 FROM information_schema.columns
    WHERE table_schema = @current_schema
      AND table_name = 'vip_level_config'
      AND column_name = 'background_card_url'
  ),
  'ALTER TABLE `vip_level_config` ADD COLUMN `background_card_url` varchar(512) NOT NULL DEFAULT '''' COMMENT ''背景卡资源URL'' AFTER `background_card_name`',
  'SELECT 1'
);
PREPARE add_vip_level_background_card_url_stmt FROM @add_vip_level_background_card_url_sql;
EXECUTE add_vip_level_background_card_url_stmt;
DEALLOCATE PREPARE add_vip_level_background_card_url_stmt;

SET @add_vip_level_effect_image_resource_id_sql := IF(
  NOT EXISTS (
    SELECT 1 FROM information_schema.columns
    WHERE table_schema = @current_schema
      AND table_name = 'vip_level_config'
      AND column_name = 'effect_image_resource_id'
  ),
  'ALTER TABLE `vip_level_config` ADD COLUMN `effect_image_resource_id` bigint NOT NULL DEFAULT 0 COMMENT ''动效图资源ID'' AFTER `background_card_url`',
  'SELECT 1'
);
PREPARE add_vip_level_effect_image_resource_id_stmt FROM @add_vip_level_effect_image_resource_id_sql;
EXECUTE add_vip_level_effect_image_resource_id_stmt;
DEALLOCATE PREPARE add_vip_level_effect_image_resource_id_stmt;

SET @add_vip_level_effect_image_name_sql := IF(
  NOT EXISTS (
    SELECT 1 FROM information_schema.columns
    WHERE table_schema = @current_schema
      AND table_name = 'vip_level_config'
      AND column_name = 'effect_image_name'
  ),
  'ALTER TABLE `vip_level_config` ADD COLUMN `effect_image_name` varchar(128) NOT NULL DEFAULT '''' COMMENT ''动效图名称'' AFTER `effect_image_resource_id`',
  'SELECT 1'
);
PREPARE add_vip_level_effect_image_name_stmt FROM @add_vip_level_effect_image_name_sql;
EXECUTE add_vip_level_effect_image_name_stmt;
DEALLOCATE PREPARE add_vip_level_effect_image_name_stmt;

SET @add_vip_level_effect_image_url_sql := IF(
  NOT EXISTS (
    SELECT 1 FROM information_schema.columns
    WHERE table_schema = @current_schema
      AND table_name = 'vip_level_config'
      AND column_name = 'effect_image_url'
  ),
  'ALTER TABLE `vip_level_config` ADD COLUMN `effect_image_url` varchar(512) NOT NULL DEFAULT '''' COMMENT ''动效图资源URL'' AFTER `effect_image_name`',
  'SELECT 1'
);
PREPARE add_vip_level_effect_image_url_stmt FROM @add_vip_level_effect_image_url_sql;
EXECUTE add_vip_level_effect_image_url_stmt;
DEALLOCATE PREPARE add_vip_level_effect_image_url_stmt;

SET @add_user_vip_short_badge_resource_id_sql := IF(
  NOT EXISTS (
    SELECT 1 FROM information_schema.columns
    WHERE table_schema = @current_schema
      AND table_name = 'user_vip_state'
      AND column_name = 'short_badge_resource_id'
  ),
  'ALTER TABLE `user_vip_state` ADD COLUMN `short_badge_resource_id` bigint NOT NULL DEFAULT 0 COMMENT ''当前短徽章资源ID'' AFTER `badge_url`',
  'SELECT 1'
);
PREPARE add_user_vip_short_badge_resource_id_stmt FROM @add_user_vip_short_badge_resource_id_sql;
EXECUTE add_user_vip_short_badge_resource_id_stmt;
DEALLOCATE PREPARE add_user_vip_short_badge_resource_id_stmt;

SET @add_user_vip_short_badge_name_sql := IF(
  NOT EXISTS (
    SELECT 1 FROM information_schema.columns
    WHERE table_schema = @current_schema
      AND table_name = 'user_vip_state'
      AND column_name = 'short_badge_name'
  ),
  'ALTER TABLE `user_vip_state` ADD COLUMN `short_badge_name` varchar(128) NOT NULL DEFAULT '''' COMMENT ''当前短徽章名称'' AFTER `short_badge_resource_id`',
  'SELECT 1'
);
PREPARE add_user_vip_short_badge_name_stmt FROM @add_user_vip_short_badge_name_sql;
EXECUTE add_user_vip_short_badge_name_stmt;
DEALLOCATE PREPARE add_user_vip_short_badge_name_stmt;

SET @add_user_vip_short_badge_url_sql := IF(
  NOT EXISTS (
    SELECT 1 FROM information_schema.columns
    WHERE table_schema = @current_schema
      AND table_name = 'user_vip_state'
      AND column_name = 'short_badge_url'
  ),
  'ALTER TABLE `user_vip_state` ADD COLUMN `short_badge_url` varchar(512) NOT NULL DEFAULT '''' COMMENT ''当前短徽章资源URL'' AFTER `short_badge_name`',
  'SELECT 1'
);
PREPARE add_user_vip_short_badge_url_stmt FROM @add_user_vip_short_badge_url_sql;
EXECUTE add_user_vip_short_badge_url_stmt;
DEALLOCATE PREPARE add_user_vip_short_badge_url_stmt;

SET @add_user_vip_background_card_resource_id_sql := IF(
  NOT EXISTS (
    SELECT 1 FROM information_schema.columns
    WHERE table_schema = @current_schema
      AND table_name = 'user_vip_state'
      AND column_name = 'background_card_resource_id'
  ),
  'ALTER TABLE `user_vip_state` ADD COLUMN `background_card_resource_id` bigint NOT NULL DEFAULT 0 COMMENT ''当前背景卡资源ID'' AFTER `float_picture_url`',
  'SELECT 1'
);
PREPARE add_user_vip_background_card_resource_id_stmt FROM @add_user_vip_background_card_resource_id_sql;
EXECUTE add_user_vip_background_card_resource_id_stmt;
DEALLOCATE PREPARE add_user_vip_background_card_resource_id_stmt;

SET @add_user_vip_background_card_name_sql := IF(
  NOT EXISTS (
    SELECT 1 FROM information_schema.columns
    WHERE table_schema = @current_schema
      AND table_name = 'user_vip_state'
      AND column_name = 'background_card_name'
  ),
  'ALTER TABLE `user_vip_state` ADD COLUMN `background_card_name` varchar(128) NOT NULL DEFAULT '''' COMMENT ''当前背景卡名称'' AFTER `background_card_resource_id`',
  'SELECT 1'
);
PREPARE add_user_vip_background_card_name_stmt FROM @add_user_vip_background_card_name_sql;
EXECUTE add_user_vip_background_card_name_stmt;
DEALLOCATE PREPARE add_user_vip_background_card_name_stmt;

SET @add_user_vip_background_card_url_sql := IF(
  NOT EXISTS (
    SELECT 1 FROM information_schema.columns
    WHERE table_schema = @current_schema
      AND table_name = 'user_vip_state'
      AND column_name = 'background_card_url'
  ),
  'ALTER TABLE `user_vip_state` ADD COLUMN `background_card_url` varchar(512) NOT NULL DEFAULT '''' COMMENT ''当前背景卡资源URL'' AFTER `background_card_name`',
  'SELECT 1'
);
PREPARE add_user_vip_background_card_url_stmt FROM @add_user_vip_background_card_url_sql;
EXECUTE add_user_vip_background_card_url_stmt;
DEALLOCATE PREPARE add_user_vip_background_card_url_stmt;

SET @add_user_vip_effect_image_resource_id_sql := IF(
  NOT EXISTS (
    SELECT 1 FROM information_schema.columns
    WHERE table_schema = @current_schema
      AND table_name = 'user_vip_state'
      AND column_name = 'effect_image_resource_id'
  ),
  'ALTER TABLE `user_vip_state` ADD COLUMN `effect_image_resource_id` bigint NOT NULL DEFAULT 0 COMMENT ''当前动效图资源ID'' AFTER `background_card_url`',
  'SELECT 1'
);
PREPARE add_user_vip_effect_image_resource_id_stmt FROM @add_user_vip_effect_image_resource_id_sql;
EXECUTE add_user_vip_effect_image_resource_id_stmt;
DEALLOCATE PREPARE add_user_vip_effect_image_resource_id_stmt;

SET @add_user_vip_effect_image_name_sql := IF(
  NOT EXISTS (
    SELECT 1 FROM information_schema.columns
    WHERE table_schema = @current_schema
      AND table_name = 'user_vip_state'
      AND column_name = 'effect_image_name'
  ),
  'ALTER TABLE `user_vip_state` ADD COLUMN `effect_image_name` varchar(128) NOT NULL DEFAULT '''' COMMENT ''当前动效图名称'' AFTER `effect_image_resource_id`',
  'SELECT 1'
);
PREPARE add_user_vip_effect_image_name_stmt FROM @add_user_vip_effect_image_name_sql;
EXECUTE add_user_vip_effect_image_name_stmt;
DEALLOCATE PREPARE add_user_vip_effect_image_name_stmt;

SET @add_user_vip_effect_image_url_sql := IF(
  NOT EXISTS (
    SELECT 1 FROM information_schema.columns
    WHERE table_schema = @current_schema
      AND table_name = 'user_vip_state'
      AND column_name = 'effect_image_url'
  ),
  'ALTER TABLE `user_vip_state` ADD COLUMN `effect_image_url` varchar(512) NOT NULL DEFAULT '''' COMMENT ''当前动效图资源URL'' AFTER `effect_image_name`',
  'SELECT 1'
);
PREPARE add_user_vip_effect_image_url_stmt FROM @add_user_vip_effect_image_url_sql;
EXECUTE add_user_vip_effect_image_url_stmt;
DEALLOCATE PREPARE add_user_vip_effect_image_url_stmt;
