Fix: missing unique key on barcode field to avoid database corruption
This commit is contained in:
parent
ce4c78972a
commit
20ef4554e0
@ -1080,3 +1080,14 @@ create table llx_categories_extrafields
|
|||||||
) ENGINE=innodb;
|
) ENGINE=innodb;
|
||||||
|
|
||||||
ALTER TABLE llx_categories_extrafields ADD INDEX idx_categories_extrafields (fk_object);
|
ALTER TABLE llx_categories_extrafields ADD INDEX idx_categories_extrafields (fk_object);
|
||||||
|
|
||||||
|
update llx_product set barcode = null where barcode in ('', '-1', '0');
|
||||||
|
update llx_societe set barcode = null where barcode in ('', '-1', '0');
|
||||||
|
|
||||||
|
-- Add missing unique keys
|
||||||
|
ALTER TABLE llx_product ADD INDEX idx_product_barcode (barcode);
|
||||||
|
ALTER TABLE llx_product ADD UNIQUE INDEX uk_product_barcode (barcode, fk_barcode_type, entity);
|
||||||
|
ALTER TABLE llx_societe ADD INDEX idx_societe_barcode (barcode);
|
||||||
|
ALTER TABLE llx_societe ADD UNIQUE INDEX uk_societe_barcode (barcode, fk_barcode_type, entity);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -103,6 +103,9 @@ update llx_opensurvey_sondage set format = 'A' where format = 'A+';
|
|||||||
-- ALTER TABLE llx_facture_fourn ALTER COLUMN fk_cond_reglement DROP NOT NULL;
|
-- ALTER TABLE llx_facture_fourn ALTER COLUMN fk_cond_reglement DROP NOT NULL;
|
||||||
|
|
||||||
|
|
||||||
|
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 barcode in llx_product. Use serveral times if you still have duplicate.
|
-- Sequence to removed duplicated values of barcode in llx_product. Use serveral times if you still have duplicate.
|
||||||
--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;
|
--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);
|
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);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user