diff --git a/crates/index-scheduler/src/upgrade/mod.rs b/crates/index-scheduler/src/upgrade/mod.rs index 74c8ee696..2053caa92 100644 --- a/crates/index-scheduler/src/upgrade/mod.rs +++ b/crates/index-scheduler/src/upgrade/mod.rs @@ -28,12 +28,17 @@ pub fn upgrade_index_scheduler( let current_minor = to.1; let current_patch = to.2; - let upgrade_functions: &[&dyn UpgradeIndexScheduler] = &[&ToCurrentNoOp {}]; + let upgrade_functions: &[&dyn UpgradeIndexScheduler] = &[ + // This is the last upgrade function, it will be called when the index is up to date. + // any other upgrade function should be added before this one. + &ToCurrentNoOp {}, + ]; let start = match from { (1, 12, _) => 0, (1, 13, _) => 0, (1, 14, _) => 0, + (1, 15, _) => 0, (major, minor, patch) => { if major > current_major || (major == current_major && minor > current_minor) diff --git a/crates/milli/src/update/upgrade/mod.rs b/crates/milli/src/update/upgrade/mod.rs index f9d971017..9f64ca0e3 100644 --- a/crates/milli/src/update/upgrade/mod.rs +++ b/crates/milli/src/update/upgrade/mod.rs @@ -8,6 +8,7 @@ use v1_13::{V1_13_0_To_V1_13_1, V1_13_1_To_Latest_V1_13}; use v1_14::Latest_V1_13_To_Latest_V1_14; use v1_15::Latest_V1_14_To_Latest_V1_15; +use crate::constants::{VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH}; use crate::progress::{Progress, VariableNameStep}; use crate::{Index, InternalError, Result}; @@ -42,6 +43,9 @@ where &V1_13_1_To_Latest_V1_13 {}, &Latest_V1_13_To_Latest_V1_14 {}, &Latest_V1_14_To_Latest_V1_15 {}, + // This is the last upgrade function, it will be called when the index is up to date. + // any other upgrade function should be added before this one. + &ToCurrentNoOp {}, ]; let start = match from { @@ -51,7 +55,7 @@ where (1, 13, _) => 4, (1, 14, _) => 5, // We must handle the current version in the match because in case of a failure some index may have been upgraded but not other. - (1, 15, _) => 5, + (1, 15, _) => 6, (major, minor, patch) => { return Err(InternalError::CannotUpgradeToVersion(major, minor, patch).into()) } @@ -87,3 +91,22 @@ where Ok(regenerate_stats) } + +#[allow(non_camel_case_types)] +struct ToCurrentNoOp {} + +impl UpgradeIndex for ToCurrentNoOp { + fn upgrade( + &self, + _wtxn: &mut RwTxn, + _index: &Index, + _original: (u32, u32, u32), + _progress: Progress, + ) -> Result { + Ok(false) + } + + fn target_version(&self) -> (u32, u32, u32) { + (VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH) + } +}