tuwunel_admin/integrity/
repair.rs1use tuwunel_core::{Err, Result, itertools::Itertools};
2use tuwunel_service::migrations::{Stamp, rerun};
3
4use crate::admin_command;
5
6#[admin_command]
7pub(super) async fn integrity_repair(
8 &self,
9 name: String,
10 yes_i_know_what_im_doing: bool,
11) -> Result {
12 if !yes_i_know_what_im_doing {
13 return Err!(
14 "Pass --yes-i-know-what-im-doing to clear the stamps, which makes the next start \
15 run the repair of {name} again."
16 );
17 }
18
19 let stamps = rerun(self.services, &name).await?;
20 let listing = stamps.format_with("", |Stamp { marker, cleared }, entry| {
21 let state = if cleared { "cleared" } else { "already pending" };
22
23 entry(&format_args!("- {marker}: {state}\n"))
24 });
25
26 self.write_string(format!(
27 "The next start with database_migrations enabled runs the repair of {name}:\n{listing}"
28 ))
29 .await
30}