SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci;
SET time_zone = '+00:00';

USE hyapp_wallet;

-- 一份政策可绑定多个区域和多个继承周期；删除旧唯一键只修改小型绑定表元数据，不读取钱包流水或周期账户。
SET @ddl := IF(
  (SELECT COUNT(*) FROM information_schema.STATISTICS
   WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'host_salary_policy_cycle_bindings' AND INDEX_NAME = 'uk_host_salary_policy_cycle_version') > 0,
  'ALTER TABLE host_salary_policy_cycle_bindings DROP INDEX uk_host_salary_policy_cycle_version, ALGORITHM=INPLACE, LOCK=NONE',
  'SELECT 1'
);
PREPARE stmt FROM @ddl;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
