From c08d0aeda5fa6e28fc1eb3b000d5310d7e3686b4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 26 Aug 2017 21:01:26 +0200 Subject: [PATCH] Clean duplicate accounting account --- htdocs/install/mysql/migration/repair.sql | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index cd55b7b38e2..14d419f3c68 100755 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -228,7 +228,7 @@ update llx_product set barcode = null where barcode in ('', '-1', '0'); update llx_societe set barcode = null where barcode in ('', '-1', '0'); --- Sequence to removed duplicated values of llx_links. Use serveral times if you still have duplicate. +-- Sequence to removed duplicated values of llx_links. Use several times if you still have duplicate. drop table tmp_links_double; --select objectid, label, max(rowid) as max_rowid, count(rowid) as count_rowid from llx_links where label is not null group by objectid, label having count(rowid) >= 2; create table tmp_links_double as (select objectid, label, max(rowid) as max_rowid, count(rowid) as count_rowid from llx_links where label is not null group by objectid, label having count(rowid) >= 2); @@ -237,7 +237,7 @@ delete from llx_links where (rowid, label) in (select max_rowid, label from tmp_ drop table tmp_links_double; --- Sequence to removed duplicated values of barcode in llx_product. Use serveral times if you still have duplicate. +-- Sequence to removed duplicated values of barcode in llx_product. Use several times if you still have duplicate. drop table tmp_product_double; --select barcode, max(rowid) as max_rowid, count(rowid) as count_rowid from llx_product where barcode is not null group by barcode having count(rowid) >= 2; create table tmp_product_double as (select barcode, max(rowid) as max_rowid, count(rowid) as count_rowid from llx_product where barcode is not null group by barcode having count(rowid) >= 2); @@ -246,7 +246,7 @@ update llx_product set barcode = null where (rowid, barcode) in (select max_rowi drop table tmp_product_double; --- Sequence to removed duplicated values of barcode in llx_societe. Use serveral times if you still have duplicate. +-- Sequence to removed duplicated values of barcode in llx_societe. Use several times if you still have duplicate. drop table tmp_societe_double; --select barcode, max(rowid) as max_rowid, count(rowid) as count_rowid from llx_societe where barcode is not null group by barcode having count(rowid) >= 2; create table tmp_societe_double as (select barcode, max(rowid) as max_rowid, count(rowid) as count_rowid from llx_societe where barcode is not null group by barcode having count(rowid) >= 2); @@ -255,6 +255,15 @@ update llx_societe set barcode = null where (rowid, barcode) in (select max_rowi drop table tmp_societe_double; +-- Sequence to removed duplicated values of llx_accounting_account. Use several times if you still have duplicate. +drop table tmp_accounting_account_double; +--select account_number, fk_pcg_version, max(rowid) as max_rowid, count(rowid) as count_rowid from llx_accounting_account where label is not null group by account_number, fk_pcg_version having count(rowid) >= 2; +create table tmp_accounting_account_double as (select account_number, fk_pcg_version, max(rowid) as max_rowid, count(rowid) as count_rowid from llx_accounting_account where label is not null group by account_number, fk_pcg_version having count(rowid) >= 2); +--select * from tmp_accounting_account_double; +delete from llx_accounting_account where (rowid) in (select max_rowid from tmp_accounting_account_double); --update to avoid duplicate, delete to delete +drop table tmp_accounting_account_double; + + UPDATE llx_projet_task SET fk_task_parent = 0 WHERE fk_task_parent = rowid;