feat(shopping): Migration 015 — Check-Keys auf Unit-Family
All checks were successful
Build & Publish Docker Image / build-and-push (push) Successful in 2m13s
All checks were successful
Build & Publish Docker Image / build-and-push (push) Successful in 2m13s
unit_key in shopping_cart_check wird von Roheinheit (g, kg, ml, l) auf Family-Key (weight, volume) umgestellt, damit Abhaks stabil bleiben wenn die Display-Einheit wechselt. Entstehende Duplikate werden durch Behalten des juengsten rowid dedupliziert. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
14
src/lib/server/db/migrations/015_shopping_check_family.sql
Normal file
14
src/lib/server/db/migrations/015_shopping_check_family.sql
Normal file
@@ -0,0 +1,14 @@
|
||||
-- Konsolidierung: unit_key in shopping_cart_check wird zum Family-Key, damit
|
||||
-- Abhaks stabil bleiben wenn Display-Unit zwischen g und kg wechselt.
|
||||
-- g/kg → 'weight', ml/l → 'volume', Rest bleibt unveraendert.
|
||||
UPDATE shopping_cart_check SET unit_key = 'weight' WHERE LOWER(TRIM(unit_key)) IN ('g', 'kg');
|
||||
UPDATE shopping_cart_check SET unit_key = 'volume' WHERE LOWER(TRIM(unit_key)) IN ('ml', 'l');
|
||||
|
||||
-- Nach Relabeling koennen Duplikate entstehen (zwei Zeilen mit 'weight' pro
|
||||
-- name_key). Juengsten Eintrag behalten.
|
||||
DELETE FROM shopping_cart_check
|
||||
WHERE rowid NOT IN (
|
||||
SELECT MAX(rowid)
|
||||
FROM shopping_cart_check
|
||||
GROUP BY name_key, unit_key
|
||||
);
|
||||
Reference in New Issue
Block a user