Move index-pattern migration to kibana plugin (#31644)
This commit is contained in:
parent
51fde9121d
commit
09336f718a
|
@ -58,6 +58,13 @@ function migrateIndexPattern(doc) {
|
|||
}
|
||||
|
||||
export const migrations = {
|
||||
'index-pattern': {
|
||||
'6.5.0': (doc) => {
|
||||
doc.attributes.type = doc.attributes.type || undefined;
|
||||
doc.attributes.typeMeta = doc.attributes.typeMeta || undefined;
|
||||
return doc;
|
||||
}
|
||||
},
|
||||
visualization: {
|
||||
'7.0.0': (doc) => {
|
||||
// Set new "references" attribute
|
||||
|
|
|
@ -19,6 +19,45 @@
|
|||
|
||||
import { migrations } from './migrations';
|
||||
|
||||
describe('index-pattern', () => {
|
||||
describe('6.5.0', () => {
|
||||
const migrate = doc => migrations['index-pattern']['6.5.0'](doc);
|
||||
|
||||
it('adds "type" and "typeMeta" properties to object when not declared', () => {
|
||||
expect(
|
||||
migrate({
|
||||
attributes: {},
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"type": undefined,
|
||||
"typeMeta": undefined,
|
||||
},
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
it('keeps "type" and "typeMeta" properties as is when declared', () => {
|
||||
expect(
|
||||
migrate({
|
||||
attributes: {
|
||||
type: '123',
|
||||
typeMeta: '123',
|
||||
},
|
||||
})
|
||||
).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"attributes": Object {
|
||||
"type": "123",
|
||||
"typeMeta": "123",
|
||||
},
|
||||
}
|
||||
`);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('visualization', () => {
|
||||
describe('7.0.0', () => {
|
||||
const migrate = doc => migrations.visualization['7.0.0'](doc);
|
||||
|
@ -354,7 +393,7 @@ Object {
|
|||
"type": "visualization",
|
||||
}
|
||||
`);
|
||||
/* eslint-enable max-len */
|
||||
/* eslint-enable max-len */
|
||||
});
|
||||
|
||||
it('skips extracting savedSearchId when missing', () => {
|
||||
|
|
|
@ -38,15 +38,6 @@ export function rollup(kibana) {
|
|||
search: [
|
||||
'plugins/rollup/search',
|
||||
],
|
||||
migrations: {
|
||||
'index-pattern': {
|
||||
'6.5.0': (doc) => {
|
||||
doc.attributes.type = doc.attributes.type || undefined;
|
||||
doc.attributes.typeMeta = doc.attributes.typeMeta || undefined;
|
||||
return doc;
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
init: function (server) {
|
||||
registerLicenseChecker(server);
|
||||
|
|
Loading…
Reference in a new issue