From 3052a166e0389c281c35d7937b0fc0ae1cc343e6 Mon Sep 17 00:00:00 2001 From: Gidi Meir Morris Date: Tue, 12 May 2020 09:43:29 +0100 Subject: [PATCH] [Task Manager] restores migrations of old tasks in TM (#65978) (#66069) When migrating to KP last week the migrations were missed - this PR restores them. --- .../server/saved_objects/index.ts | 2 ++ .../server/saved_objects/migrations.ts | 21 ++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/x-pack/plugins/task_manager/server/saved_objects/index.ts b/x-pack/plugins/task_manager/server/saved_objects/index.ts index 0ad9021cd7f39..fbb54b566ece0 100644 --- a/x-pack/plugins/task_manager/server/saved_objects/index.ts +++ b/x-pack/plugins/task_manager/server/saved_objects/index.ts @@ -6,6 +6,7 @@ import { SavedObjectsServiceSetup } from 'kibana/server'; import mappings from './mappings.json'; +import { migrations } from './migrations'; import { TaskManagerConfig } from '../config.js'; export function setupSavedObjects( @@ -18,6 +19,7 @@ export function setupSavedObjects( hidden: true, convertToAliasScript: `ctx._id = ctx._source.type + ':' + ctx._id`, mappings: mappings.task, + migrations, indexPattern: config.index, }); } diff --git a/x-pack/plugins/task_manager/server/saved_objects/migrations.ts b/x-pack/plugins/task_manager/server/saved_objects/migrations.ts index 1c2cf73d0fe13..617ef80749d6a 100644 --- a/x-pack/plugins/task_manager/server/saved_objects/migrations.ts +++ b/x-pack/plugins/task_manager/server/saved_objects/migrations.ts @@ -3,22 +3,23 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { SavedObject } from '../../../../../src/core/server'; +import { SavedObjectMigrationMap, SavedObjectUnsanitizedDoc } from '../../../../../src/core/server'; +import { TaskInstance, TaskInstanceWithDeprecatedFields } from '../task'; -export const migrations = { - task: { - '7.4.0': (doc: SavedObject>) => ({ - ...doc, - updated_at: new Date().toISOString(), - }), - '7.6.0': moveIntervalIntoSchedule, - }, +export const migrations: SavedObjectMigrationMap = { + '7.4.0': doc => ({ + ...doc, + updated_at: new Date().toISOString(), + }), + '7.6.0': moveIntervalIntoSchedule, }; function moveIntervalIntoSchedule({ attributes: { interval, ...attributes }, ...doc -}: SavedObject>) { +}: SavedObjectUnsanitizedDoc): SavedObjectUnsanitizedDoc< + TaskInstance +> { return { ...doc, attributes: {