From b50572e87a1a9c5ab28270abb11673b62ea4af51 Mon Sep 17 00:00:00 2001 From: Heitor Mattosinho Date: Thu, 11 Feb 2021 12:52:34 -0300 Subject: [PATCH] fix (case/delete): case properties preventing delete --- .../app/Controllers/Http/v1/CaseController.js | 11 ++++++++++- src/adonisjs/app/Models/v1/Case.js | 8 ++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/adonisjs/app/Controllers/Http/v1/CaseController.js b/src/adonisjs/app/Controllers/Http/v1/CaseController.js index de02c51..8769ba8 100644 --- a/src/adonisjs/app/Controllers/Http/v1/CaseController.js +++ b/src/adonisjs/app/Controllers/Http/v1/CaseController.js @@ -192,9 +192,18 @@ class CaseController { const trx = await Database.beginTransaction() try { const c = await Case.findBy('id', request.input('caseId')) - + console.log('============ =============================') if (c != null) { await c.versions().delete() + await Permission + .query() + .where('table', 'cases') + .where('table_id', c.id) + .delete() + await CaseProperty + .query() + .where('case_id', c.id) + .delete() // await c.users().detach() // await c.quests().detach() await c.artifacts().delete() diff --git a/src/adonisjs/app/Models/v1/Case.js b/src/adonisjs/app/Models/v1/Case.js index 31bcae9..29a0526 100644 --- a/src/adonisjs/app/Models/v1/Case.js +++ b/src/adonisjs/app/Models/v1/Case.js @@ -15,10 +15,10 @@ class Case extends Model { artifacts () { return this.hasMany('App/Models/CaseArtifact') } - - permissions () { - return this.hasMany('App/Models/v1/Permission') - } + // + // permissions () { + // return this.hasMany('App/Models/v1/Permission') + // } author () { return this.belongsTo('App/Models/v1/User')