mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-03 20:07:09 +02:00
starts adding tests and fix the starts of meilisearch
This commit is contained in:
parent
3ef7a478cd
commit
102681e384
9 changed files with 106 additions and 52 deletions
|
@ -14,8 +14,8 @@ use crate::upgrade::v1_11::v1_10_to_v1_11;
|
|||
|
||||
pub struct OfflineUpgrade {
|
||||
pub db_path: PathBuf,
|
||||
pub current_version: (String, String, String),
|
||||
pub target_version: (String, String, String),
|
||||
pub current_version: (u32, u32, u32),
|
||||
pub target_version: (u32, u32, u32),
|
||||
}
|
||||
|
||||
impl OfflineUpgrade {
|
||||
|
@ -50,7 +50,7 @@ impl OfflineUpgrade {
|
|||
|
||||
let upgrade_list = [
|
||||
(
|
||||
v1_9_to_v1_10 as fn(&Path, &str, &str, &str) -> Result<(), anyhow::Error>,
|
||||
v1_9_to_v1_10 as fn(&Path, u32, u32, u32) -> Result<(), anyhow::Error>,
|
||||
"1",
|
||||
"10",
|
||||
"0",
|
||||
|
@ -62,18 +62,14 @@ impl OfflineUpgrade {
|
|||
|
||||
let no_upgrade: usize = upgrade_list.len();
|
||||
|
||||
let (current_major, current_minor, current_patch) = &self.current_version;
|
||||
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,
|
||||
let start_at = match (current_major, current_minor, current_patch) {
|
||||
(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,
|
||||
|
@ -81,16 +77,13 @@ impl OfflineUpgrade {
|
|||
}
|
||||
};
|
||||
|
||||
let (target_major, target_minor, target_patch) = &self.target_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.")
|
||||
}
|
||||
let ends_at = match (target_major, target_minor, target_patch) {
|
||||
(1, 10, _) => 0,
|
||||
(1, 11, _) => 1,
|
||||
(1, 12, x) if x == 0 || x == 1 || x == 2 => 2,
|
||||
(1, 12, 3 | 4 | 5) => 3,
|
||||
_ => {
|
||||
bail!("Unsupported target version {target_major}.{target_minor}.{target_patch}. Can only upgrade to versions in range [{}-{}]",
|
||||
FIRST_SUPPORTED_UPGRADE_TO_VERSION,
|
||||
|
|
|
@ -153,9 +153,9 @@ fn date_round_trip(
|
|||
|
||||
pub fn v1_9_to_v1_10(
|
||||
db_path: &Path,
|
||||
_origin_major: &str,
|
||||
_origin_minor: &str,
|
||||
_origin_patch: &str,
|
||||
_origin_major: u32,
|
||||
_origin_minor: u32,
|
||||
_origin_patch: u32,
|
||||
) -> anyhow::Result<()> {
|
||||
println!("Upgrading from v1.9.0 to v1.10.0");
|
||||
// 2 changes here
|
||||
|
|
|
@ -16,9 +16,9 @@ use crate::{try_opening_database, try_opening_poly_database};
|
|||
|
||||
pub fn v1_10_to_v1_11(
|
||||
db_path: &Path,
|
||||
_origin_major: &str,
|
||||
_origin_minor: &str,
|
||||
_origin_patch: &str,
|
||||
_origin_major: u32,
|
||||
_origin_minor: u32,
|
||||
_origin_patch: u32,
|
||||
) -> anyhow::Result<()> {
|
||||
println!("Upgrading from v1.10.0 to v1.11.0");
|
||||
|
||||
|
|
|
@ -25,9 +25,9 @@ use crate::uuid_codec::UuidCodec;
|
|||
|
||||
pub fn v1_11_to_v1_12(
|
||||
db_path: &Path,
|
||||
_origin_major: &str,
|
||||
_origin_minor: &str,
|
||||
_origin_patch: &str,
|
||||
_origin_major: u32,
|
||||
_origin_minor: u32,
|
||||
_origin_patch: u32,
|
||||
) -> anyhow::Result<()> {
|
||||
println!("Upgrading from v1.11.0 to v1.12.0");
|
||||
|
||||
|
@ -38,13 +38,13 @@ pub fn v1_11_to_v1_12(
|
|||
|
||||
pub fn v1_12_to_v1_12_3(
|
||||
db_path: &Path,
|
||||
origin_major: &str,
|
||||
origin_minor: &str,
|
||||
origin_patch: &str,
|
||||
origin_major: u32,
|
||||
origin_minor: u32,
|
||||
origin_patch: u32,
|
||||
) -> anyhow::Result<()> {
|
||||
println!("Upgrading from v1.12.{{0, 1, 2}} to v1.12.3");
|
||||
|
||||
if origin_minor == "12" {
|
||||
if origin_minor == 12 {
|
||||
rebuild_field_distribution(db_path)?;
|
||||
} else {
|
||||
println!("Not rebuilding field distribution as it wasn't corrupted coming from v{origin_major}.{origin_minor}.{origin_patch}");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue