记录任务下发历史和接收是否成功

This commit is contained in:
2025-09-25 00:17:01 +08:00
parent 6b931648dc
commit e2e21601f4
7 changed files with 161 additions and 29 deletions

View File

@@ -146,14 +146,14 @@ func (ps *PostgresStorage) creatingHyperTable() error {
}
ps.logger.Info("成功将 sensor_data 转换为超表 (或已转换)")
// 将 downlink_task_records 转换为超表
// 'sent_at' 是 DownlinkTaskRecord 模型中定义的时间列
sqlDownlinkTaskRecords := "SELECT create_hypertable('downlink_task_records', 'sent_at', if_not_exists => TRUE);"
if err := ps.db.Exec(sqlDownlinkTaskRecords).Error; err != nil {
ps.logger.Errorw("将 downlink_task_records 转换为超表失败", "error", err)
return fmt.Errorf("将 downlink_task_records 转换为超表失败: %w", err)
// 将 device_command_log 转换为超表
// 'sent_at' 是 DeviceCommandLog 模型中定义的时间列
sqlDeviceCommandLogs := "SELECT create_hypertable('device_command_log', 'sent_at', if_not_exists => TRUE);"
if err := ps.db.Exec(sqlDeviceCommandLogs).Error; err != nil {
ps.logger.Errorw("将 device_command_log 转换为超表失败", "error", err)
return fmt.Errorf("将 device_command_log 转换为超表失败: %w", err)
}
ps.logger.Info("成功将 downlink_task_records 转换为超表 (或已转换)")
ps.logger.Info("成功将 device_command_log 转换为超表 (或已转换)")
return nil
}