mirror of
https://github.com/strapi/strapi.git
synced 2025-11-12 16:22:10 +00:00
feat: do not delete the last workflow
This commit is contained in:
parent
38377a89b7
commit
72c08abd23
@ -132,6 +132,12 @@ module.exports = ({ strapi }) => {
|
|||||||
async delete(workflow, opts) {
|
async delete(workflow, opts) {
|
||||||
const stageService = getService('stages', { strapi });
|
const stageService = getService('stages', { strapi });
|
||||||
|
|
||||||
|
const workflowCount = await this.count();
|
||||||
|
|
||||||
|
if (workflowCount <= 1) {
|
||||||
|
throw new ApplicationError('Can not delete the last workflow');
|
||||||
|
}
|
||||||
|
|
||||||
return strapi.db.transaction(async () => {
|
return strapi.db.transaction(async () => {
|
||||||
// Delete stages
|
// Delete stages
|
||||||
await stageService.deleteMany(workflow.stages.map((stage) => stage.id));
|
await stageService.deleteMany(workflow.stages.map((stage) => stage.id));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user