Repository: meilisearch/meilisearch
File: crates/meilitool/src/upgrade/mod.rs (Rust)

Code before:
        let (current_major, current_minor, current_patch) = &self.current_version;

        let start_at = match (
            current_major.as_str(),
            current_minor.as_str(),
            current_patch.as_str(),
        ) {
            ("1", "9", _) => 0,
            ("1", "10", _) => 1,
            ("1", "11", _) => 2,
            ("1", "12", x) if x == "0" || x == "1" || x == "2" => 3,
            ("1", "12", x) if x == "3" || x == "4" || x == "5" => no_upgrade,
            _ => {
                bail!("Unsupported current version {current_major}.{current_minor}.{current_patch}. Can only upgrade from versions in range [{}-{}]",
                      FIRST_SUPPORTED_UPGRADE_FROM_VERSION,
                      LAST_SUPPORTED_UPGRADE_FROM_VERSION);
            }
        };

        let (target_major, target_minor, target_patch) = &self.target_version;

        let ends_at = match (target_major.as_str(), target_minor.as_str(), target_patch.as_str()) {
            ("1", "10", _) => 0,
            ("1", "11", _) => 1,
            ("1", "12", x) if x == "0" || x == "1" || x == "2" => 2,
            ("1", "12", x) if x == "3" || x == "4" || x == "5" => 3,
            (major, _, _) if major.starts_with('v') => {
                bail!("Target version must not starts with a `v`. Instead of writing `v1.9.0` write `1.9.0` for example.")
            }
            _ => {
                bail!("Unsupported target version {target_major}.{target_minor}.{target_patch}. Can only upgrade to versions in range [{}-{}]",
                      FIRST_SUPPORTED_UPGRADE_TO_VERSION,
                      LAST_SUPPORTED_UPGRADE_TO_VERSION);
            }
        };

        println!("Starting the upgrade from {current_major}.{current_minor}.{current_patch} to {target_major}.{target_minor}.{target_patch}");

        if start_at == no_upgrade {
            println!("No upgrade operation to perform, writing VERSION file");
            create_version_file(&self.db_path, target_major, target_minor, target_patch)
                .context("while writing VERSION file after the upgrade")?;
            println!("Success");
            return Ok(());
        }

        #[allow(clippy::needless_range_loop)]
        for index in start_at..=ends_at {
            let (func, major, minor, patch) = upgrade_list[index];
            (func)(&self.db_path, current_major, current_minor, current_patch)?;
            println!("Done");

Review comment (suggestion):
```suggestion
            ("1", "12", 3 | 4 | 5) => 3,
```

I you want

Code after:
        let (current_major, current_minor, current_patch) = &self.current_version;

        let start_at = match (
            current_major.as_str(),
            current_minor.as_str(),
            current_patch.as_str(),
        ) {
            ("1", "9", _) => 0,
            ("1", "10", _) => 1,
            ("1", "11", _) => 2,
            ("1", "12", "0" | "1" | "2") => 3,
            ("1", "12", "3" | "4" | "5") => no_upgrade,
            _ => {
                bail!("Unsupported current version {current_major}.{current_minor}.{current_patch}. Can only upgrade from versions in range [{}-{}]",
                      FIRST_SUPPORTED_UPGRADE_FROM_VERSION,
                      LAST_SUPPORTED_UPGRADE_FROM_VERSION);
            }
        };

        let (target_major, target_minor, target_patch) = &self.target_version;

        let ends_at = match (target_major.as_str(), target_minor.as_str(), target_patch.as_str()) {
            ("1", "10", _) => 0,
            ("1", "11", _) => 1,
            ("1", "12", "0" | "1" | "2") => 2,
            ("1", "12", "3" | "4" | "5") => 3,
            (major, _, _) if major.starts_with('v') => {
                bail!("Target version must not starts with a `v`. Instead of writing `v1.9.0` write `1.9.0` for example.")
            }
            _ => {
                bail!("Unsupported target version {target_major}.{target_minor}.{target_patch}. Can only upgrade to versions in range [{}-{}]",
                      FIRST_SUPPORTED_UPGRADE_TO_VERSION,
                      LAST_SUPPORTED_UPGRADE_TO_VERSION);
            }
        };

        println!("Starting the upgrade from {current_major}.{current_minor}.{current_patch} to {target_major}.{target_minor}.{target_patch}");

        if start_at == no_upgrade {
            println!("No upgrade operation to perform, writing VERSION file");
            create_version_file(&self.db_path, target_major, target_minor, target_patch)
                .context("while writing VERSION file after the upgrade")?;
            println!("Success");
            return Ok(());
        }

        #[allow(clippy::needless_range_loop)]
        for index in start_at..=ends_at {
            let (func, major, minor, patch) = upgrade_list[index];
            (func)(&self.db_path, current_major, current_minor, current_patch)?;
            println!("Done");