[Saved Objects] Update the migrationVersion property to hold a plain string value (#150075)

* Update document migrator to rely on `typeMigrationVersion` instead of `migrationVersion`.
* Refactor document migrator to extract migration pipeline logic.
* Add `core` migration type.
This commit is contained in:
Michael Dokolin 2023-03-24 13:45:30 +01:00 committed by GitHub
parent 1a0cab832d
commit 17876df41a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
69 changed files with 1205 additions and 828 deletions

View file

@ -25,7 +25,10 @@ export interface SavedObjectsBulkCreateObject<T = unknown> {
version?: string;
/** Array of references to other saved objects */
references?: SavedObjectReference[];
/** {@inheritDoc SavedObjectsMigrationVersion} */
/**
* {@inheritDoc SavedObjectsMigrationVersion}
* @deprecated
*/
migrationVersion?: SavedObjectsMigrationVersion;
/**
* A semver value that is used when upgrading objects between Kibana versions. If undefined, this will be automatically set to the current
@ -37,6 +40,8 @@ export interface SavedObjectsBulkCreateObject<T = unknown> {
* field set and you want to create it again.
*/
coreMigrationVersion?: string;
/** A semver value that is used when migrating documents between Kibana versions. */
typeMigrationVersion?: string;
/** Optional ID of the original saved object, if this object's `id` was regenerated */
originId?: string;
/**

View file

@ -25,7 +25,10 @@ export interface SavedObjectsCreateOptions extends SavedObjectsBaseOptions {
* Can be used in conjunction with `overwrite` for implementing optimistic concurrency control.
**/
version?: string;
/** {@inheritDoc SavedObjectsMigrationVersion} */
/**
* {@inheritDoc SavedObjectsMigrationVersion}
* @deprecated Use {@link SavedObjectsCreateOptions.typeMigrationVersion} instead.
*/
migrationVersion?: SavedObjectsMigrationVersion;
/**
* A semver value that is used when upgrading objects between Kibana versions. If undefined, this will be automatically set to the current
@ -37,6 +40,10 @@ export interface SavedObjectsCreateOptions extends SavedObjectsBaseOptions {
* field set and you want to create it again.
*/
coreMigrationVersion?: string;
/**
* A semver value that is used when migrating documents between Kibana versions.
*/
typeMigrationVersion?: string;
/** Array of references to other saved objects */
references?: SavedObjectReference[];
/** The Elasticsearch Refresh setting for this operation */

View file

@ -21,8 +21,15 @@ export interface SavedObjectsIncrementCounterOptions<Attributes = unknown>
* already exist. Existing fields will be left as-is and won't be incremented.
*/
initialize?: boolean;
/** {@link SavedObjectsMigrationVersion} */
/**
* {@link SavedObjectsMigrationVersion}
* @deprecated
*/
migrationVersion?: SavedObjectsMigrationVersion;
/**
* A semver value that is used when migrating documents between Kibana versions.
*/
typeMigrationVersion?: string;
/**
* (default='wait_for') The Elasticsearch refresh setting for this
* operation. See {@link MutatingOperationRefreshSetting}

View file

@ -76,7 +76,6 @@ export interface ISavedObjectsRepository {
* @param {object} [options={}] {@link SavedObjectsCreateOptions} - options for the create operation
* @property {string} [options.id] - force id on creation, not recommended
* @property {boolean} [options.overwrite=false]
* @property {object} [options.migrationVersion=undefined]
* @property {string} [options.namespace]
* @property {array} [options.references=[]] - [{ name, type, id }]
* @returns {promise} the created saved object { id, type, version, attributes }