mirror of
https://github.com/strapi/strapi.git
synced 2025-11-03 03:17:11 +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) {
|
||||
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 () => {
|
||||
// Delete stages
|
||||
await stageService.deleteMany(workflow.stages.map((stage) => stage.id));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user