Move index-pattern migration to kibana plugin (#31644)

This commit is contained in:
Mike Côté 2019-02-21 10:04:15 -05:00 committed by GitHub
parent 51fde9121d
commit 09336f718a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 47 additions and 10 deletions

View file

@ -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

View file

@ -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', () => {

View file

@ -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);