summaryrefslogtreecommitdiffstats
path: root/sql
diff options
context:
space:
mode:
authorSebastian Reichel <sre@ring0.de>2013-05-24 00:12:42 +0200
committerSebastian Reichel <sre@ring0.de>2013-05-24 00:12:42 +0200
commit591b7537a26b79389eb2295b2c0afc8b4c35df67 (patch)
tree641af6c7d554b4f431dc6c003344c13a0e3b021c /sql
parent1105c32181ebaed1aebad6b44624227e9c83e9ee (diff)
downloadserial-barcode-scanner-591b7537a26b79389eb2295b2c0afc8b4c35df67.tar.bz2
add minimal support for deprecation flag
Diffstat (limited to 'sql')
-rw-r--r--sql/tables.sql2
-rw-r--r--sql/views.sql1
2 files changed, 2 insertions, 1 deletions
diff --git a/sql/tables.sql b/sql/tables.sql
index 194f4f3..91a36d1 100644
--- a/sql/tables.sql
+++ b/sql/tables.sql
@@ -1,5 +1,5 @@
BEGIN TRANSACTION;
-CREATE TABLE IF NOT EXISTS products (id INTEGER PRIMARY KEY NOT NULL, name TEXT, amount INTEGER NOT NULL DEFAULT 0);
+CREATE TABLE IF NOT EXISTS products (id INTEGER PRIMARY KEY NOT NULL, name TEXT, amount INTEGER NOT NULL DEFAULT 0, deprecated BOOLEAN NOT NULL DEFAULT 0);
CREATE TABLE IF NOT EXISTS sales (user INTEGER NOT NULL REFERENCES users, product INTEGER NOT NULL REFERENCES products, timestamp INTEGER NOT NULL DEFAULT 0);
CREATE TABLE IF NOT EXISTS restock (user INTEGER NOT NULL REFERENCES users, product INTEGER NOT NULL REFERENCES products, amount INTEGER NOT NULL DEFAULT 0, timestamp INTEGER NOT NULL DEFAULT 0, price INTEGER NOT NULL DEFAULT 0, supplier INTEGER, best_before_date INTEGER);
CREATE TABLE IF NOT EXISTS prices (product INTEGER NOT NULL REFERENCES products, valid_from INTEGER NOT NULL DEFAULT 0, memberprice INTEGER NOT NULL DEFAULT 0, guestprice INTEGER NOT NULL DEFAULT 0);
diff --git a/sql/views.sql b/sql/views.sql
index 8edfa9f..4b138fe 100644
--- a/sql/views.sql
+++ b/sql/views.sql
@@ -1,4 +1,5 @@
BEGIN TRANSACTION;
+CREATE VIEW IF NOT EXISTS stock AS SELECT id, name, amount FROM products WHERE deprecated = 0 OR amount != 0;
CREATE VIEW IF NOT EXISTS purchaseprices AS SELECT product, SUM(price * amount) / SUM(amount) AS price FROM restock GROUP BY product;
CREATE VIEW IF NOT EXISTS invoice AS
SELECT user, timestamp, id AS productid, name AS productname,