diff --git a/db/changes/234001/00-updateWeight.sql b/db/changes/234001/00-updateWeight.sql index 6f224667d..29c3ef8ae 100644 --- a/db/changes/234001/00-updateWeight.sql +++ b/db/changes/234001/00-updateWeight.sql @@ -1,49 +1,11 @@ --- algunas medias se quedan muy fuera de lugar -UPDATE `vn`.`item` i - JOIN( - SELECT typeFk, AVG(`size`) `size` - FROM vn.item - WHERE `size` > 0 - AND `size` IS NOT NULL - GROUP BY typeFk - ) sub ON sub.typeFk = i.typeFk - SET i.`size` = sub.`size` - WHERE i.`size` IS NULL; - -ALTER TABLE `vn`.`item` MODIFY COLUMN `size` int(10) NOT NULL; - -UPDATE `vn`.`item` i - JOIN( - SELECT typeFk, AVG(weightByPiece / `size`) grams - FROM vn.item - WHERE weightByPiece IS NOT NULL - AND weightByPiece > 0 - AND `size` > 0 - AND `size` IS NOT NULL - GROUP BY typeFk - ) sub ON sub.typeFk = i.typeFk - SET i.weightByPiece = sub.grams * `size` - WHERE weightByPiece IS NULL - OR weightByPiece = 0; +ALTER TABLE `vn`.`item` MODIFY COLUMN `size` int(10) NOT NULL DEFAULT ; ALTER TABLE `vn`.`item` MODIFY COLUMN weightByPiece int(10) NOT NULL - COMMENT 'peso por defecto para un articulo por tallo/unidad'; - --- revisar algunos se quedan fuera - -UPDATE `vn`.`buy` b - SET b.packing = IFNULL(b.grouping, 0) * 2 - WHERE b.packing IS NULL; + COMMENT 'peso por defecto para un articulo por tallo/unidad' DEFAULT ; ALTER TABLE `vn`.`buy` MODIFY COLUMN packing int(11) DEFAULT 0 NOT NULL; -UPDATE `vn`.`buy` b - JOIN `vn`.`item` i ON i.id = b.itemFk - SET b.weight = (i.weightByPiece * b.packing) / 1000 - WHERE weight IS NULL - OR weight = 0; - ALTER TABLE `vn`.`buy` MODIFY COLUMN `weight` decimal(10,2) NOT NULL; \ No newline at end of file