mirror of
https://github.com/grocy/grocy.git
synced 2025-08-19 20:11:16 +00:00
Fixed per unit stock grocycodes weren't unique per unit (fixes #1676)
This commit is contained in:
21
migrations/0156.sql
Normal file
21
migrations/0156.sql
Normal file
@@ -0,0 +1,21 @@
|
||||
DROP VIEW stock_splits;
|
||||
CREATE VIEW stock_splits
|
||||
AS
|
||||
|
||||
/*
|
||||
Helper view which shows splitted stock rows which could be compacted
|
||||
(a stock_id starting with "x" indicates that this entry shouldn't be compacted)
|
||||
*/
|
||||
|
||||
SELECT
|
||||
product_id,
|
||||
SUM(amount) AS total_amount,
|
||||
MIN(stock_id) AS stock_id_to_keep,
|
||||
MAX(id) AS id_to_keep,
|
||||
GROUP_CONCAT(id) AS id_group,
|
||||
GROUP_CONCAT(stock_id) AS stock_id_group,
|
||||
id -- Dummy
|
||||
FROM stock
|
||||
WHERE stock_id NOT LIKE 'x%'
|
||||
GROUP BY product_id, best_before_date, purchased_date, price, open, opened_date, location_id, shopping_location_id
|
||||
HAVING COUNT(*) > 1;
|
Reference in New Issue
Block a user