diff --git a/src/core/server/ui_settings/saved_objects/migrations.ts b/src/core/server/ui_settings/saved_objects/migrations.ts index 7ea5573076ba0..850fc6d7d46c0 100644 --- a/src/core/server/ui_settings/saved_objects/migrations.ts +++ b/src/core/server/ui_settings/saved_objects/migrations.ts @@ -28,4 +28,32 @@ export const migrations = { }), references: doc.references || [], }), + '7.12.0': (doc: SavedObjectUnsanitizedDoc): SavedObjectSanitizedDoc => ({ + ...doc, + ...(doc.attributes && { + attributes: Object.keys(doc.attributes).reduce((acc, key) => { + if (key === 'timepicker:quickRanges' && doc.attributes[key].indexOf('section') > -1) { + const ranges = JSON.parse(doc.attributes[key]).map( + ({ from, to, display }: { from: string; to: string; display: string }) => { + return { + from, + to, + display, + }; + } + ); + return { + ...acc, + 'timepicker:quickRanges': JSON.stringify(ranges, null, 2), + }; + } else { + return { + ...acc, + [key]: doc.attributes[key], + }; + } + }, {}), + }), + references: doc.references || [], + }), };