-- Replace fa_ with the configured database prefix when executing manually. CREATE TABLE IF NOT EXISTS `fa_grain_forecast` ( `id` int unsigned NOT NULL AUTO_INCREMENT, `gid` int unsigned NOT NULL, `granary_name` varchar(100) NOT NULL, `storage` varchar(255) NOT NULL DEFAULT '', `grain_type` varchar(10) NOT NULL, `observed_date` date NOT NULL, `tm_i` decimal(8,4) NOT NULL, `tm_o` decimal(8,4) NOT NULL, `hm_i` decimal(8,4) NOT NULL, `hm_o` decimal(8,4) NOT NULL, `request_key` varchar(64) NOT NULL, `status` varchar(12) NOT NULL DEFAULT 'pending', `error` varchar(255) NOT NULL DEFAULT '', `attempt_time` int unsigned NOT NULL DEFAULT 0, `admin_id` int unsigned NOT NULL DEFAULT 0, `create_time` int unsigned NOT NULL, `update_time` int unsigned NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `request_key` (`request_key`), KEY `gid_id` (`gid`,`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='人工温湿度及预测批次'; CREATE TABLE IF NOT EXISTS `fa_grain_forecast_point` ( `id` int unsigned NOT NULL AUTO_INCREMENT, `forecast_id` int unsigned NOT NULL, `horizon` tinyint unsigned NOT NULL, `target_date` date NOT NULL, `predicted` text NOT NULL, `actual` text NOT NULL, `actual_date` date DEFAULT NULL, `actual_admin_id` int unsigned NOT NULL DEFAULT 0, `version` int unsigned NOT NULL DEFAULT 0, `update_time` int unsigned NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `forecast_horizon` (`forecast_id`,`horizon`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='预测目标日期与人工实测对比';