SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci;

USE hyapp_wallet;

-- 与顶层生产迁移 073 保持同一事实。旧迁移已可能物化用户选择，
-- 所以这里只用 INSTANT DDL 修改后续 INSERT 的列默认，绝不更新现有行。
SET @ddl := IF(
  (SELECT COUNT(*) FROM information_schema.COLUMNS
   WHERE TABLE_SCHEMA = DATABASE()
     AND TABLE_NAME = 'user_vip_settings'
     AND COLUMN_NAME IN (
       'room_entry_notice_enabled',
       'online_global_notice_enabled',
       'hide_profile_data_enabled',
       'anonymous_profile_visit_enabled',
       'leaderboard_invisible_enabled'
     )) = 5,
  'ALTER TABLE user_vip_settings
     ALTER COLUMN room_entry_notice_enabled SET DEFAULT TRUE,
     ALTER COLUMN online_global_notice_enabled SET DEFAULT TRUE,
     ALTER COLUMN hide_profile_data_enabled SET DEFAULT FALSE,
     ALTER COLUMN anonymous_profile_visit_enabled SET DEFAULT FALSE,
     ALTER COLUMN leaderboard_invisible_enabled SET DEFAULT FALSE,
     ALGORITHM=INSTANT',
  'SELECT 1'
);
PREPARE stmt FROM @ddl;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
