Debug log the latest saved object migrations per type (#89722)

* Debug log the latest saved object migrations per type

* Fix broken test
This commit is contained in:
Rudolf Meijering 2021-02-02 10:42:38 +01:00 committed by GitHub
parent 69f4c9d541
commit 7fbec26594
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View file

@ -119,8 +119,8 @@ describe('KibanaMigrator', () => {
const migrator = new KibanaMigrator(options);
expect(() => migrator.runMigrations()).rejects.toThrow(
/Migrations are not ready. Make sure prepareMigrations is called first./i
await expect(() => migrator.runMigrations()).toThrowErrorMatchingInlineSnapshot(
`"Migrations are not ready. Make sure prepareMigrations is called first."`
);
});

View file

@ -12,6 +12,7 @@
*/
import { BehaviorSubject } from 'rxjs';
import Semver from 'semver';
import { KibanaConfigType } from '../../../kibana_config';
import { ElasticsearchClient } from '../../../elasticsearch';
import { Logger } from '../../../logging';
@ -163,6 +164,15 @@ export class KibanaMigrator {
registry: this.typeRegistry,
});
this.log.debug('Applying registered migrations for the following saved object types:');
Object.entries(this.documentMigrator.migrationVersion)
.sort(([t1, v1], [t2, v2]) => {
return Semver.compare(v1, v2);
})
.forEach(([type, migrationVersion]) => {
this.log.debug(`migrationVersion: ${migrationVersion} saved object type: ${type}`);
});
const migrators = Object.keys(indexMap).map((index) => {
// TODO migrationsV2: remove old migrations algorithm
if (this.savedObjectsConfig.enableV2) {