From 4555bf3b63112872e8290f99b40f9bc973600ba0 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Sun, 21 Feb 2021 18:55:48 +0100 Subject: [PATCH] Enforce product barcodes to be unique (references #1205) --- changelog/62_UNRELEASED_xxxx-xx-xx.md | 20 ++++++++++++++++---- migrations/0128.sql | 13 +++++++++++++ 2 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 migrations/0128.sql diff --git a/changelog/62_UNRELEASED_xxxx-xx-xx.md b/changelog/62_UNRELEASED_xxxx-xx-xx.md index 63e6e97a..e7bd4eec 100644 --- a/changelog/62_UNRELEASED_xxxx-xx-xx.md +++ b/changelog/62_UNRELEASED_xxxx-xx-xx.md @@ -1,9 +1,21 @@ -- Fixed that tracking chores with "Done by" a different user was not possible +### Stock improvements/fixes +- Product barcodes are now enforced to be unique across products - Fixed that editing stock entries was not possible -- Fixed that shopping list prints had a grey background (thanks @Forceu) -- Improved/fixed the form validation on the shopping list item page (thanks @Forceu) - Fixed that consuming with Scan Mode was not possible - Fixed that the current stock total value (header of the stock overview page) didn't include decimal amounts (thanks @Ape) -- Some night mode style improvements (thanks @BlizzWave and @KTibow) + +### Shopping list fixes +- Fixed that shopping list prints had a grey background (thanks @Forceu) +- Fixed the form validation on the shopping list item page (thanks @Forceu) + +### Recipe improvements - Recipe printing improvements (thanks @Ape) + +### Chores fixes +- Fixed that tracking chores with "Done by" a different user was not possible + +### General & other improvements +- Some night mode style improvements (thanks @BlizzWave and @KTibow) + +### API fixes - Fixed that due soon products with `due_type` = "Expiration date" were missing in `due_products` of the `/stock/volatile` endpoint diff --git a/migrations/0128.sql b/migrations/0128.sql new file mode 100644 index 00000000..9acb2bbd --- /dev/null +++ b/migrations/0128.sql @@ -0,0 +1,13 @@ +-- Duplicate product barcodes were most probably not created on purpose, +-- so just keep the newer one for any duplicates +DELETE FROM product_barcodes +WHERE id IN ( + SELECT MIN(id) + FROM product_barcodes + GROUP BY barcode + HAVING COUNT(*) > 1 +); + +CREATE UNIQUE INDEX ix_product_barcodes ON product_barcodes ( + barcode +);