From a9a935558c4e5a08f5e9c3d40c1acad3cb54eda7 Mon Sep 17 00:00:00 2001 From: Rudolf Meijering Date: Thu, 21 Jan 2021 22:53:01 +0100 Subject: [PATCH] Try to fix v2 migrations for pre-release builds --- src/core/server/saved_objects/migrationsv2/model.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/core/server/saved_objects/migrationsv2/model.ts b/src/core/server/saved_objects/migrationsv2/model.ts index ba2508bf73cce..6760e8cd0780f 100644 --- a/src/core/server/saved_objects/migrationsv2/model.ts +++ b/src/core/server/saved_objects/migrationsv2/model.ts @@ -707,6 +707,9 @@ export const createInitialState = ({ migrationVersionPerType: SavedObjectsMigrationVersion; indexPrefix: string; }): InitState => { + // Convert the kibanaVersion to lower case so that it's valid for using in an + // index name. This is necessary for pre-release builds like `8.0.0-SNAPSHOT` + const kibanaVersionLc = kibanaVersion.toLowerCase(); const outdatedDocumentsQuery = { bool: { should: Object.entries(migrationVersionPerType).map(([type, latestVersion]) => ({ @@ -736,10 +739,10 @@ export const createInitialState = ({ indexPrefix, legacyIndex: indexPrefix, currentAlias: indexPrefix, - versionAlias: `${indexPrefix}_${kibanaVersion}`, - versionIndex: `${indexPrefix}_${kibanaVersion}_001`, - tempIndex: `${indexPrefix}_${kibanaVersion}_reindex_temp`, - kibanaVersion, + versionAlias: `${indexPrefix}_${kibanaVersionLc}`, + versionIndex: `${indexPrefix}_${kibanaVersionLc}_001`, + tempIndex: `${indexPrefix}_${kibanaVersionLc}_reindex_temp`, + kibanaVersion: kibanaVersionLc, preMigrationScript: Option.fromNullable(preMigrationScript), targetIndexMappings: targetMappings, tempIndexMappings: reindexTargetMappings,