CREATE TABLE `query` (
                                 `id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '主键ID',
                                 `order_id` BIGINT NOT NULL COMMENT '订单ID（软关联到订单表）',
                                 `user_id` BIGINT NOT NULL COMMENT '用户ID（直接关联到用户）',
                                 `product_id` BIGINT NOT NULL COMMENT '产品ID（直接关联到产品）',
                                 `query_params` TEXT NOT NULL COMMENT '查询params数据',
                                 `query_data` LONGTEXT COMMENT '查询结果数据',
                                 `query_state` ENUM('pending', 'success', 'failed') NOT NULL DEFAULT 'pending' COMMENT '查询状态',
                                 `del_state` TINYINT NOT NULL DEFAULT '0' COMMENT '删除状态',
                                 `version` BIGINT NOT NULL DEFAULT '0' COMMENT '版本号',
                                 `create_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
                                 `update_time` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
                                 `delete_time` DATETIME DEFAULT NULL COMMENT '删除时间',
                                 PRIMARY KEY (`id`),
                                 UNIQUE KEY `unique_order_id` (`order_id`),
                                 KEY `idx_user_id` (`user_id`),
                                 KEY `idx_product_id` (`product_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='查询结果表，存储关联订单的查询数据';
