Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,14 @@ describe('successful migrations', () => {
});
});
});

describe('8.0.0', () => {
test('no op migration for rules SO', () => {
const migration800 = getActionTaskParamsMigrations(encryptedSavedObjectsSetup, [])['8.0.0'];
const actionTaskParam = getMockData();
expect(migration800(actionTaskParam, context)).toEqual(actionTaskParam);
});
});
});

describe('handles errors during migrations', () => {
Expand Down Expand Up @@ -402,7 +410,8 @@ describe('isPreconfiguredAction()', () => {

function getMockData(
overwrites: Record<string, unknown> = {},
referencesOverwrites: SavedObjectReference[] = []
referencesOverwrites: SavedObjectReference[] = [],
namespaces: string[] = ['default']
): SavedObjectUnsanitizedDoc<ActionTaskParams> {
return {
attributes: {
Expand All @@ -412,6 +421,7 @@ function getMockData(
},
references: [...referencesOverwrites],
id: uuid.v4(),
namespaces,
type: 'action_task_param',
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,17 @@ export function getActionTaskParamsMigrations(
pipeMigrations(getUseSavedObjectReferencesFn(preconfiguredActions))
);

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

return {
'7.16.0': executeMigrationWithErrorHandling(migrationActionTaskParamsSixteen, '7.16.0'),
'8.0.0': executeMigrationWithErrorHandling(migrationActionsTaskParams800, '8.0.0'),
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ describe('successful migrations', () => {
});
});
});

describe('8.0.0', () => {
test('no op migration for rules SO', () => {
const migration800 = getActionsMigrations(encryptedSavedObjectsSetup)['8.0.0'];
const action = getMockData({});
expect(migration800(action, context)).toEqual(action);
});
});
});

describe('handles errors during migrations', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,18 @@ export function getActionsMigrations(
pipeMigrations(addisMissingSecretsField)
);

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

return {
'7.10.0': executeMigrationWithErrorHandling(migrationActionsTen, '7.10.0'),
'7.11.0': executeMigrationWithErrorHandling(migrationActionsEleven, '7.11.0'),
'7.14.0': executeMigrationWithErrorHandling(migrationActionsFourteen, '7.14.0'),
'8.0.0': executeMigrationWithErrorHandling(migrationActions800, '8.0.0'),
};
}

Expand Down
6 changes: 4 additions & 2 deletions x-pack/plugins/actions/server/saved_objects/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export function setupSavedObjects(
savedObjects.registerType({
name: ACTION_SAVED_OBJECT_TYPE,
hidden: true,
namespaceType: 'single',
namespaceType: 'multiple-isolated',
convertToMultiNamespaceTypeVersion: '8.0.0',
mappings: mappings.action as SavedObjectsTypeMappingDefinition,
migrations: getActionsMigrations(encryptedSavedObjects),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to add a no-op migration for the ACTION_SAVED_OBJECT_TYPE type too, right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah.., I forgot about this. Thank you for pointing!

management: {
Expand Down Expand Up @@ -71,7 +72,8 @@ export function setupSavedObjects(
savedObjects.registerType({
name: ACTION_TASK_PARAMS_SAVED_OBJECT_TYPE,
hidden: true,
namespaceType: 'single',
namespaceType: 'multiple-isolated',
convertToMultiNamespaceTypeVersion: '8.0.0',
mappings: mappings.action_task_params as SavedObjectsTypeMappingDefinition,
migrations: getActionTaskParamsMigrations(encryptedSavedObjects, preconfiguredActions),
excludeOnUpgrade: async ({ readonlyEsClient }) => {
Expand Down