mirror of
https://github.com/strapi/strapi.git
synced 2025-08-11 02:07:51 +00:00
fix: remove unnecessary migration
This commit is contained in:
parent
cc69ffc92e
commit
c62acb8c5f
@ -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 };
|
@ -9,9 +9,6 @@ const defaultStages = require('../../constants/default-stages.json');
|
||||
const defaultWorkflow = require('../../constants/default-workflow.json');
|
||||
const { ENTITY_STAGE_ATTRIBUTE } = require('../../constants/workflows');
|
||||
|
||||
const {
|
||||
disableOnContentTypes: disableReviewWorkflows,
|
||||
} = require('../../migrations/review-workflows');
|
||||
const { getDefaultWorkflow } = require('../../utils/review-workflows');
|
||||
|
||||
async function initDefaultWorkflow({ workflowsService, stagesService, strapi }) {
|
||||
@ -103,7 +100,6 @@ module.exports = ({ strapi }) => {
|
||||
async register() {
|
||||
extendReviewWorkflowContentTypes({ strapi });
|
||||
strapi.hook('strapi::content-types.afterSync').register(enableReviewWorkflow({ strapi }));
|
||||
strapi.hook('strapi::content-types.afterSync').register(disableReviewWorkflows);
|
||||
},
|
||||
};
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user