Merge pull request #17983 from strapi/fix/workflow-name-is-reseted-when-downgrade-ce

This commit is contained in:
Marc Roig 2023-09-08 15:39:10 +02:00 committed by GitHub
commit a8580fef02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,6 +3,10 @@
const { WORKFLOW_MODEL_UID } = require('../constants/workflows');
const defaultWorkflow = require('../constants/default-workflow.json');
/**
* Multiple workflows introduced the ability to name a workflow.
* This migration adds the default workflow name if the name attribute was added.
*/
async function migrateReviewWorkflowName({ oldContentTypes, contentTypes }) {
// Look for RW name attribute
const hadName = !!oldContentTypes?.[WORKFLOW_MODEL_UID]?.attributes?.name;
@ -11,6 +15,9 @@ async function migrateReviewWorkflowName({ oldContentTypes, contentTypes }) {
// Add the default workflow name if name attribute was added
if (!hadName && hasName) {
await strapi.query(WORKFLOW_MODEL_UID).updateMany({
where: {
name: { $null: true },
},
data: {
name: defaultWorkflow.name,
},