Skip to content

Commit

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

* [Task Manager] restores migrations of old tasks in TM (elastic#65978)

When migrating to KP last week the migrations were missed - this PR restores them.

* removed broken types
  • Loading branch information
gmmorris committed May 12, 2020
1 parent 193f6f7 commit 261e30f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 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,
});
}
23 changes: 10 additions & 13 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,19 @@
* 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 } from '../../../../../src/core/server';

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>>) {
// Type is wrong here and will be fixed by platform in https://github.com/elastic/kibana/issues/64748
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function moveIntervalIntoSchedule({ attributes: { interval, ...attributes }, ...doc }: any): any {
return {
...doc,
attributes: {
Expand Down

0 comments on commit 261e30f

Please sign in to comment.