diff --git a/packages/plugin-collections/src/hooks/collections-after-update.ts b/packages/plugin-collections/src/hooks/collections-after-update.ts new file mode 100644 index 0000000000..e0c65c2739 --- /dev/null +++ b/packages/plugin-collections/src/hooks/collections-after-update.ts @@ -0,0 +1,8 @@ +import CollectionModel from '../models/collection'; + +export default async function (model: CollectionModel, options: any = {}) { + const { migrate = true } = options; + if (migrate) { + await model.migrate(options); + } +} diff --git a/packages/plugin-collections/src/hooks/index.ts b/packages/plugin-collections/src/hooks/index.ts index aebc0b9b13..f5ce259a22 100644 --- a/packages/plugin-collections/src/hooks/index.ts +++ b/packages/plugin-collections/src/hooks/index.ts @@ -1,16 +1,18 @@ import collectionsBeforeValidate from './collections-before-validate'; import collectionsAfterCreate from './collections-after-create'; +import collectionsAfterUpdate from './collections-after-update'; import fieldsBeforeValidate from './fields-before-validate'; import fieldsAfterCreate from './fields-after-create'; -import generateName from './generateName'; import fieldsAfterBulkUpdate from './fields-after-bulk-update'; +import generateName from './generateName'; + export default { collections: { beforeValidate: collectionsBeforeValidate, afterCreate: collectionsAfterCreate, - afterUpdate: collectionsAfterCreate, + afterUpdate: collectionsAfterUpdate, }, fields: { beforeValidate: fieldsBeforeValidate,