From 1ac51b6e06cce706a1279d847907273e94d8b6f9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 4 Apr 2019 13:46:01 +0200 Subject: [PATCH] More complete example to fix migration error from v8 --- htdocs/install/mysql/migration/8.0.0-9.0.0.sql | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql index 643e411ee5e..d1cc00f403f 100644 --- a/htdocs/install/mysql/migration/8.0.0-9.0.0.sql +++ b/htdocs/install/mysql/migration/8.0.0-9.0.0.sql @@ -272,10 +272,15 @@ UPDATE llx_const set name = 'PRELEVEMENT_USTRD' where name = 'USTRD'; -- Delete duplicate accounting account, but only if not used DROP TABLE tmp_llx_accouting_account; -CREATE TABLE tmp_llx_accouting_account AS SELECT MIN(rowid) as MINID, account_number, entity, fk_pcg_version, count(*) AS NB FROM llx_accounting_account group BY account_number, entity, fk_pcg_version HAVING count(*) >= 2 order by account_number, entity, fk_pcg_version; +CREATE TABLE tmp_llx_accouting_account AS SELECT MIN(rowid) as MINID, MAX(rowid) as MAXID, account_number, entity, fk_pcg_version, count(*) AS NB FROM llx_accounting_account group BY account_number, entity, fk_pcg_version HAVING count(*) >= 2 order by account_number, entity, fk_pcg_version; --SELECT * from tmp_llx_accouting_account; DELETE from llx_accounting_account where rowid in (select minid from tmp_llx_accouting_account where minid NOT IN (SELECT fk_code_ventilation from llx_facturedet) AND minid NOT IN (SELECT fk_code_ventilation from llx_facture_fourn_det) AND minid NOT IN (SELECT fk_code_ventilation from llx_expensereport_det)); +-- If there is record in tmp_llx_accouting_account, make a look on each line to do +--update llx_facturedet set fk_code_ventilation = maxid WHERE fk_code_ventilation = minid; +--update llx_facture_fourn_det set fk_code_ventilation = maxid WHERE fk_code_ventilation = minid; +--update llx_expensereport_det set fk_code_ventilation = maxid WHERE fk_code_ventilation = minid; + ALTER TABLE llx_accounting_account DROP INDEX uk_accounting_account; ALTER TABLE llx_accounting_account ADD UNIQUE INDEX uk_accounting_account (account_number, entity, fk_pcg_version);