SET @drop_shop_key_machine_no_index_sql := (
    SELECT CASE
        WHEN COUNT(*) > 0 THEN 'ALTER TABLE biz_shop_key DROP INDEX uk_machine_no'
        ELSE 'SELECT 1'
    END
    FROM information_schema.STATISTICS
    WHERE TABLE_SCHEMA = DATABASE()
      AND TABLE_NAME = 'biz_shop_key'
      AND INDEX_NAME = 'uk_machine_no'
);
PREPARE stmt FROM @drop_shop_key_machine_no_index_sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;

SET @drop_shop_key_machine_no_column_sql := (
    SELECT CASE
        WHEN COUNT(*) > 0 THEN 'ALTER TABLE biz_shop_key DROP COLUMN machine_no'
        ELSE 'SELECT 1'
    END
    FROM information_schema.COLUMNS
    WHERE TABLE_SCHEMA = DATABASE()
      AND TABLE_NAME = 'biz_shop_key'
      AND COLUMN_NAME = 'machine_no'
);
PREPARE stmt FROM @drop_shop_key_machine_no_column_sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
