From 2aa6868f1372b87c598ae7c613c596d7fd0a8bd5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Feb 2023 12:17:17 +0100 Subject: [PATCH] Complete the repair to remove orphelins states and regions --- htdocs/install/mysql/migration/repair.sql | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index a33143f8aef..0d3aa4dc51d 100644 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -576,3 +576,13 @@ DELETE FROM llx_rights_def WHERE module = 'hrm' AND perms = 'employee'; -- DROP TABLE tmp_bank2; -- CREATE TABLE tmp_bank2 SELECT b.rowid, b.amount, p.rowid as pid, p.amount as pamount, p.multicurrency_amount as pmulticurrencyamount FROM llx_bank as b INNER JOIN llx_bank_url as bu ON bu.fk_bank=b.rowid AND bu.type = 'payment_supplier' INNER JOIN llx_paiementfourn as p ON bu.url_id = p.rowid WHERE p.multicurrency_amount <> 0 AND p.multicurrency_amount <> p.amount; -- UPDATE llx_bank as b SET b.amount_main_currency = (SELECT tb.pamount FROM tmp_bank2 as tb WHERE tb.rowid = b.rowid) WHERE b.amount_main_currency IS NULL; + + +-- Delete duplicate entries into llx_c_transport_mode +-- VMYSQL4.1 DELETE T1 FROM llx_c_transport_mode as T1, llx_c_transport_mode as T2 where T1.entity = T2.entity AND T1.code = T2.code and T1.rowid > T2.rowid; +-- VPGSQL8.2 DELETE FROM llx_c_transport_mode as T1 WHERE rowid NOT IN (SELECT min(rowid) FROM llx_c_transport_mode GROUP BY code, entity); + +-- Delete department of regions linked to no coutry, then delete region with no country +DELETE FROM llx_c_departements WHERE fk_region <> 0 AND fk_region IN (select code_region FROM llx_c_regions WHERE fk_pays NOT IN (select rowid from llx_c_country)); +DELETE from llx_c_regions WHERE fk_pays NOT IN (select rowid from llx_c_country); +