fix: snapshot existing config before update; rollback returns 200

This commit is contained in:
2026-03-17 14:41:57 +01:00
parent bd498b9bcb
commit 45c05b5720
2 changed files with 7 additions and 5 deletions

View File

@@ -130,5 +130,5 @@ pub(super) async fn rollback_schedule(
let detail = format!("rollback to gen {}; {} slots", target.generation, schedule.slots.len()); let detail = format!("rollback to gen {}; {} slots", target.generation, schedule.slots.len());
let _ = state.activity_log_repo.log("schedule_rollback", &detail, Some(channel_id)).await; let _ = state.activity_log_repo.log("schedule_rollback", &detail, Some(channel_id)).await;
Ok((StatusCode::CREATED, Json(ScheduleResponse::from(schedule)))) Ok(Json(ScheduleResponse::from(schedule)))
} }

View File

@@ -44,10 +44,12 @@ impl ChannelService {
} }
pub async fn update(&self, channel: Channel) -> DomainResult<Channel> { pub async fn update(&self, channel: Channel) -> DomainResult<Channel> {
// Auto-snapshot the config being replaced // Auto-snapshot the existing config before overwriting
self.channel_repo if let Some(existing) = self.channel_repo.find_by_id(channel.id).await? {
.save_config_snapshot(channel.id, &channel.schedule_config, None) self.channel_repo
.await?; .save_config_snapshot(channel.id, &existing.schedule_config, None)
.await?;
}
self.channel_repo.save(&channel).await?; self.channel_repo.save(&channel).await?;
Ok(channel) Ok(channel)
} }