SET @add_profile_bg_img := (
  SELECT IF(
    COUNT(*) = 0,
    'ALTER TABLE users ADD COLUMN profile_bg_img VARCHAR(512) NOT NULL DEFAULT '''' COMMENT ''个人主页信息卡背景图'' AFTER avatar',
    'SELECT 1'
  )
  FROM information_schema.COLUMNS
  WHERE TABLE_SCHEMA = DATABASE()
    AND TABLE_NAME = 'users'
    AND COLUMN_NAME = 'profile_bg_img'
);

PREPARE stmt FROM @add_profile_bg_img;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
