Save current product barcode into new product_barcodes table

This commit is contained in:
Kurt Riddlesperger 2020-05-04 17:15:21 -05:00
parent 410a0f0094
commit 9b388247da

View File

@ -25,6 +25,19 @@ qu_factor_purchase_to_stock REAL NOT NULL DEFAULT 1,
shopping_location_id INTEGER
);
--Convert product table to new barcode table
INSERT INTO product_barcodes (product_id, barcode, qu_factor_purchase_to_stock, shopping_location_id)
WITH split(id, barcode, str, qu_factor_purchase_to_stock, shopping_location_id) AS (
select id as product_id, '', barcode||',' ,qu_factor_purchase_to_stock, shopping_location_id from products
UNION ALL SELECT
id as product_id,
substr(str, 0, instr(str, ',')),
substr(str, instr(str, ',')+1),
qu_factor_purchase_to_stock,
shopping_location_id
FROM split WHERE str!=''
) SELECT id as product_id, barcode, qu_factor_purchase_to_stock, shopping_location_id FROM split WHERE barcode!='';
ALTER TABLE products RENAME TO products_old;
--Remove barcode column