Skip to content

Commit

Permalink
Debug log the latest saved object migrations per type (#89722)
Browse files Browse the repository at this point in the history
* Debug log the latest saved object migrations per type

* Fix broken test
  • Loading branch information
rudolf authored Feb 2, 2021
1 parent 69f4c9d commit 7fbec26
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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."`
);
});

Expand Down
10 changes: 10 additions & 0 deletions src/core/server/saved_objects/migrations/kibana/kibana_migrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 7fbec26

Please sign in to comment.