mirror of
https://github.com/grocy/grocy.git
synced 2025-04-30 01:55:47 +00:00
Fixed migration when having unsupported parent/child product nesting levels (fixes #1542)
This commit is contained in:
parent
cf382bb47f
commit
53e405c4f8
@ -1,2 +1,4 @@
|
|||||||
- Fixed that the upgrade failed when having "> 2 times duplicate" (means the same barcode was added more than 2 times) product barcodes
|
- Fixed that the upgrade failed when having "> 2 times duplicate" (means the same barcode was added more than 2 times) product barcodes
|
||||||
- Fixed that when having any "Track date only" chore on the calendar, the iCal export was broken
|
- Fixed that when having any "Track date only" chore on the calendar, the iCal export was broken
|
||||||
|
- Fixed that the upgrade failed when having unsupported parent/child product nesting levels
|
||||||
|
- More information on this: Only 1 level is currently supported; creating > 1 level nestings was _never_ possible via the UI/frontend, but not checked/enforced by the backend before `v3.0.0` - so it was potentially possible via the API (or any third party app/tool which utilizes it) to create such a nesting which then made this upgrade to fail
|
||||||
|
@ -1,3 +1,33 @@
|
|||||||
|
/*
|
||||||
|
|
||||||
|
Parent/child product relations are currently limited to 1 level.
|
||||||
|
|
||||||
|
This was enforced by the UI/frontend since ever, but on the backend/database only
|
||||||
|
since v3.0.0 (by the trigger enfore_product_nesting_level).
|
||||||
|
|
||||||
|
So via the API (or any third party app/tool which utilizes it), it was potentially possible
|
||||||
|
to create > 1 level nestings before v3.0.0.
|
||||||
|
|
||||||
|
The ALTER TABLE statement below does technically an update on all product rows (due to the column default value),
|
||||||
|
so > 1 level nestings would make this fail.
|
||||||
|
|
||||||
|
=> So clean up those unsupported nesting levels here.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
-- Clears parent_product_id for any > 1 level nesting (which is currently unsupported)
|
||||||
|
UPDATE products
|
||||||
|
SET parent_product_id = NULL
|
||||||
|
WHERE id IN (
|
||||||
|
SELECT
|
||||||
|
p_child.id
|
||||||
|
FROM products p_parent
|
||||||
|
JOIN products p_child
|
||||||
|
ON p_parent.parent_product_id = p_child.id
|
||||||
|
WHERE p_parent.parent_product_id IS NOT NULL
|
||||||
|
)
|
||||||
|
AND parent_product_id IS NOT NULL;
|
||||||
|
|
||||||
ALTER TABLE products
|
ALTER TABLE products
|
||||||
ADD default_print_stock_label INTEGER NOT NULL DEFAULT 0;
|
ADD default_print_stock_label INTEGER NOT NULL DEFAULT 0;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user