fix: prevent workflow name to be reseted when CE -> EE

Workflow name was reseted to 'Default' when upgrading to EE, because the migration files compares the workflow content type between the migration, and on CE -> EE the workflow content type does not exist in CE
This commit is contained in:
Marc-Roig 2023-09-08 14:35:42 +02:00
parent ba65bb5b8a
commit 61d65e72f6
No known key found for this signature in database
GPG Key ID: FB4E2C43A0BEE249

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,
},