SET @table_schema = DATABASE();

SET @ddl = IF(
    EXISTS(
        SELECT 1
        FROM information_schema.COLUMNS
        WHERE TABLE_SCHEMA = @table_schema
          AND TABLE_NAME = 'order_user_purchase_pay'
          AND COLUMN_NAME = 'app_version'
    ),
    'SELECT 1',
    "ALTER TABLE `order_user_purchase_pay` ADD COLUMN `app_version` varchar(32) NOT NULL DEFAULT '' COMMENT '本次充值请求的App版本' AFTER `reference_id`"
);
PREPARE stmt FROM @ddl;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
