From e6a2701bc8b3352ace2fa931baa5d50707c919f6 Mon Sep 17 00:00:00 2001 From: Martin Date: Fri, 13 Jan 2017 07:17:45 +0100 Subject: [PATCH] PW-619 refactor material price --- migrations/000.027.sql | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 migrations/000.027.sql diff --git a/migrations/000.027.sql b/migrations/000.027.sql new file mode 100644 index 0000000..314444d --- /dev/null +++ b/migrations/000.027.sql @@ -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; \ No newline at end of file