PW-619 refactor material price

This commit is contained in:
Martin
2017-01-13 07:17:45 +01:00
parent 69ff764fdf
commit e6a2701bc8
+23
View File
@@ -0,0 +1,23 @@
-- PW-619: refactor material prices
-- create the new price column
DO $$
BEGIN
BEGIN
ALTER TABLE "product-materials" ADD COLUMN price integer NOT NULL DEFAULT 1;
EXCEPTION
WHEN duplicate_column THEN RAISE NOTICE 'column price already exists in "product-materials".';
END;
END;
$$;
-- populate with default data
UPDATE "product-materials" SET price = 23600 WHERE materialid = 1;
UPDATE "product-materials" SET price = 35600 WHERE materialid = 2;
UPDATE "product-materials" SET price = 79920 WHERE materialid = 3;
UPDATE "product-materials" SET price = 26000 WHERE materialid = 4;
-- drop old views that are no longer used
DROP VIEW IF EXISTS v_materialprice;