Skip to content

Commit

Permalink
[Alerting] [8.0] Prepare for making alerting saved objects sharecapab…
Browse files Browse the repository at this point in the history
…le (#109990)

* [Alerting] [8.0] Prepare for making alerting saved objects sharecapable

* removed v8 check

* removed link

* added no op migration

* fixed name

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
YulNaumenko and kibanamachine authored Aug 26, 2021
1 parent c43429c commit 382a5f1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion x-pack/plugins/alerting/server/saved_objects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ export function setupSavedObjects(
savedObjects.registerType({
name: 'alert',
hidden: true,
namespaceType: 'single',
namespaceType: 'multiple-isolated',
convertToMultiNamespaceTypeVersion: '8.0.0',
migrations: getMigrations(encryptedSavedObjects),
mappings: mappings.alert as SavedObjectsTypeMappingDefinition,
management: {
Expand Down
13 changes: 13 additions & 0 deletions x-pack/plugins/alerting/server/saved_objects/migrations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1430,6 +1430,19 @@ describe('successful migrations', () => {
});
});
});

describe('8.0.0', () => {
test('no op migration for rules SO', () => {
const migration800 = getMigrations(encryptedSavedObjectsSetup)['8.0.0'];
const alert = getMockData({}, true);
expect(migration800(alert, migrationContext)).toEqual({
...alert,
attributes: {
...alert.attributes,
},
});
});
});
});

describe('handles errors during migrations', () => {
Expand Down
7 changes: 7 additions & 0 deletions x-pack/plugins/alerting/server/saved_objects/migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ export function getMigrations(
pipeMigrations(setLegacyId)
);

const migrationRules800 = createEsoMigration(
encryptedSavedObjects,
(doc: SavedObjectUnsanitizedDoc<RawAlert>): doc is SavedObjectUnsanitizedDoc<RawAlert> => true,
(doc) => doc // no-op
);

return {
'7.10.0': executeMigrationWithErrorHandling(migrationWhenRBACWasIntroduced, '7.10.0'),
'7.11.0': executeMigrationWithErrorHandling(migrationAlertUpdatedAtAndNotifyWhen, '7.11.0'),
Expand All @@ -113,6 +119,7 @@ export function getMigrations(
'7.14.1': executeMigrationWithErrorHandling(migrationSecurityRules714, '7.14.1'),
'7.15.0': executeMigrationWithErrorHandling(migrationSecurityRules715, '7.15.0'),
'7.16.0': executeMigrationWithErrorHandling(migrateLegacyIds716, '7.16.0'),
'8.0.0': executeMigrationWithErrorHandling(migrationRules800, '8.0.0'),
};
}

Expand Down

0 comments on commit 382a5f1

Please sign in to comment.