Skip to content

Commit

Permalink
add tables deleted and cleared by ReplaceAll to the confirmation warn…
Browse files Browse the repository at this point in the history
…ing (#31739)

The ReplaceAll mode for snapshot imports should show a confirmation warning that includes the tables cleared and deleted.
Currently the warning only shows the tables that are present in the import, because those are the ones touched by `--replace`.

GitOrigin-RevId: 6a57c71682d10e49128865e81f86bbaf947b4119
  • Loading branch information
ldanilek authored and Convex, Inc. committed Nov 22, 2024
1 parent 47b7790 commit f178fff
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion crates/application/src/snapshot_import/confirmation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,27 @@ async fn messages_to_confirm_replace<RT: Runtime>(
}
}

let mut table_changes = BTreeMap::new();
let db_snapshot = executor.database.latest_snapshot()?;

// Add to count_by_table all tables that are being replaced that don't appear in
// the import.
if mode == ImportMode::ReplaceAll {
let component_paths = db_snapshot.component_ids_to_paths();
let table_mapping = db_snapshot.table_mapping();
for (tablet_id, namespace, _, table_name) in table_mapping.iter() {
let Some(component_path) = component_paths.get(&namespace.into()) else {
continue;
};
if !table_mapping.is_active(tablet_id) {
continue;
}
count_by_table
.entry((component_path.clone(), table_name.clone()))
.or_default();
}
}

let mut table_changes = BTreeMap::new();
for (component_and_table, count_importing) in count_by_table.iter() {
let (component_path, table_name) = component_and_table;
let existing_num_values = db_snapshot
Expand Down

0 comments on commit f178fff

Please sign in to comment.