SET @current_schema = DATABASE();

SELECT CHARACTER_MAXIMUM_LENGTH
INTO @notice_event_id_length
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = @current_schema
  AND TABLE_NAME = 'order_user_purchase_pay_notice'
  AND COLUMN_NAME = 'event_id'
LIMIT 1;

SET @ddl = IF(
    @notice_event_id_length IS NOT NULL AND @notice_event_id_length < 512,
    'ALTER TABLE `order_user_purchase_pay_notice` MODIFY COLUMN `event_id` varchar(512) NOT NULL DEFAULT '''' COMMENT ''事件标识''',
    'SELECT 1'
);

PREPARE stmt FROM @ddl;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
