fix: remove unnecessary migration

This commit is contained in:
Marc-Roig 2023-04-17 14:03:10 +02:00
parent cc69ffc92e
commit c62acb8c5f
2 changed files with 0 additions and 43 deletions

View File

@ -1,39 +0,0 @@
'use strict';
const { hasReviewWorkflow } = require('../utils/review-workflows');
/**
* Remove all stage information for all content types that have had review workflows disabled
*/
/* eslint-disable no-continue */
const disableOnContentTypes = async ({ oldContentTypes, contentTypes }) => {
const uidsToRemove = [];
for (const uid in contentTypes) {
if (!oldContentTypes || !oldContentTypes[uid]) {
continue;
}
const oldContentType = oldContentTypes[uid];
const contentType = contentTypes?.[uid];
if (
hasReviewWorkflow({ strapi }, oldContentType) &&
!hasReviewWorkflow({ strapi }, contentType)
) {
// If review workflows has been turned off on a content type
// remove stage information from all entities within this CT
uidsToRemove.push(uid);
}
}
if (uidsToRemove.length === 0) {
return;
}
await strapi.db
.connection('strapi_workflows_stages_related_morphs')
.whereIn('related_type', uidsToRemove)
.del();
};
module.exports = { disableOnContentTypes };

View File

@ -9,9 +9,6 @@ const defaultStages = require('../../constants/default-stages.json');
const defaultWorkflow = require('../../constants/default-workflow.json'); const defaultWorkflow = require('../../constants/default-workflow.json');
const { ENTITY_STAGE_ATTRIBUTE } = require('../../constants/workflows'); const { ENTITY_STAGE_ATTRIBUTE } = require('../../constants/workflows');
const {
disableOnContentTypes: disableReviewWorkflows,
} = require('../../migrations/review-workflows');
const { getDefaultWorkflow } = require('../../utils/review-workflows'); const { getDefaultWorkflow } = require('../../utils/review-workflows');
async function initDefaultWorkflow({ workflowsService, stagesService, strapi }) { async function initDefaultWorkflow({ workflowsService, stagesService, strapi }) {
@ -103,7 +100,6 @@ module.exports = ({ strapi }) => {
async register() { async register() {
extendReviewWorkflowContentTypes({ strapi }); extendReviewWorkflowContentTypes({ strapi });
strapi.hook('strapi::content-types.afterSync').register(enableReviewWorkflow({ strapi })); strapi.hook('strapi::content-types.afterSync').register(enableReviewWorkflow({ strapi }));
strapi.hook('strapi::content-types.afterSync').register(disableReviewWorkflows);
}, },
}; };
}; };