From 3408f67348ef1bc5118d9ec17d01382c920db20e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Apr 2020 16:00:09 +0200 Subject: [PATCH] Clean orhpelins in llx_product_association --- htdocs/install/mysql/migration/repair.sql | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 7f5e6fafe3d..4297c5f324d 100644 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -165,6 +165,10 @@ DELETE FROM llx_product_batch WHERE qty = 0; UPDATE llx_product p SET p.stock= (SELECT SUM(ps.reel) FROM llx_product_stock ps WHERE ps.fk_product = p.rowid); +-- Fix: delete orphelins in product_association +delete from llx_product_association where fk_product_pere NOT IN (select rowid from llx_product); +delete from llx_product_association where fk_product_fils NOT IN (select rowid from llx_product); + -- Fix: delete category child with no category parent. drop table tmp_categorie; create table tmp_categorie as select * from llx_categorie;