Browse Source

Remove also blog post relation with categories

Vova Tkach 6 years ago
parent
commit
21258afc42
1 changed files with 6 additions and 1 deletions
  1. 6 1
      modules/module_blog_categories.go

+ 6 - 1
modules/module_blog_categories.go

@@ -300,7 +300,7 @@ func (this *Modules) RegisterAction_BlogCategoriesDelete() *Action {
 		}
 
 		// Start transaction with table lock
-		_, err := wrap.DB.Exec("LOCK TABLE blog_cats WRITE;")
+		_, err := wrap.DB.Exec("LOCK TABLES blog_cats WRITE, blog_cat_post_rel WRITE;")
 		if err != nil {
 			wrap.MsgError(err.Error())
 			return
@@ -337,6 +337,11 @@ func (this *Modules) RegisterAction_BlogCategoriesDelete() *Action {
 			wrap.MsgError(err.Error())
 			return
 		}
+		if _, err = tx.Exec("DELETE FROM blog_cat_post_rel WHERE category_id = ?;", pf_id); err != nil {
+			tx.Rollback()
+			wrap.MsgError(err.Error())
+			return
+		}
 
 		// Commit all changes and unlock table
 		err = tx.Commit()