Workaround for crap product specific QU conversions for migration 0207 (fixes #2285)

This commit is contained in:
Bernd Bestel 2023-07-31 16:58:41 +02:00
parent fd7e24b7d1
commit 73ad9d39ab
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
2 changed files with 5 additions and 3 deletions

View File

@ -8,7 +8,8 @@
### Stock
- Performance fixes related to the stock overview and purchase/consume/inventory/transfer page
- Fixed performance issues related to the stock overview and purchase/consume/inventory/transfer page
- Fixed that the upgrade failed when having improperly defined product specific quantity unit conversions
### Shopping list

View File

@ -40,8 +40,9 @@ INSERT INTO quantity_unit_conversions
(from_qu_id, to_qu_id, factor, product_id)
SELECT p.qu_id_purchase, p.qu_id_stock, IFNULL(p.qu_factor_purchase_to_stock, 1.0), p.id
FROM products p
WHERE p.qu_id_stock != qu_id_purchase
AND NOT EXISTS(SELECT 1 FROM quantity_unit_conversions WHERE product_id = p.id AND from_qu_id = p.qu_id_stock AND to_qu_id = p.qu_id_purchase);
WHERE p.qu_id_stock != p.qu_id_purchase
AND NOT EXISTS(SELECT 1 FROM quantity_unit_conversions WHERE product_id = p.id AND from_qu_id = p.qu_id_stock AND to_qu_id = p.qu_id_purchase)
AND NOT EXISTS(SELECT 1 FROM quantity_unit_conversions WHERE product_id = p.id AND from_qu_id = p.qu_id_purchase AND to_qu_id = p.qu_id_stock);
-- ALTER TABLE DROP COLUMN is only available in SQLite >= 3.35.0 (we require 3.34.0 as of now), so can't be used
PRAGMA legacy_alter_table = ON;