Skip to content

Commit

Permalink
[Task Manager] restores migrations of old tasks in TM (elastic#65978) (
Browse files Browse the repository at this point in the history
…elastic#66069)

When migrating to KP last week the migrations were missed - this PR restores them.
  • Loading branch information
gmmorris authored May 12, 2020
1 parent b96e57d commit 3052a16
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
2 changes: 2 additions & 0 deletions x-pack/plugins/task_manager/server/saved_objects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -18,6 +19,7 @@ export function setupSavedObjects(
hidden: true,
convertToAliasScript: `ctx._id = ctx._source.type + ':' + ctx._id`,
mappings: mappings.task,
migrations,
indexPattern: config.index,
});
}
21 changes: 11 additions & 10 deletions x-pack/plugins/task_manager/server/saved_objects/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Record<string, unknown>>) => ({
...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<Record<string, unknown>>) {
}: SavedObjectUnsanitizedDoc<TaskInstanceWithDeprecatedFields>): SavedObjectUnsanitizedDoc<
TaskInstance
> {
return {
...doc,
attributes: {
Expand Down

0 comments on commit 3052a16

Please sign in to comment.