X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/859394a5b4389f497ce493d11d29882ef66f2e47..9589ecd776677cdeb2fbaf8de211963d24cf5aa1:/sql/Pg-upgrade2/price_rules.sql

diff --git a/sql/Pg-upgrade2/price_rules.sql b/sql/Pg-upgrade2/price_rules.sql
new file mode 100644
index 000000000..3f62fd203
--- /dev/null
+++ b/sql/Pg-upgrade2/price_rules.sql
@@ -0,0 +1,35 @@
+-- @tag: price_rules
+-- @description:  Preismatrix Tabellen
+-- @depends: release_3_1_0
+-- @encoding: utf-8
+
+CREATE TABLE price_rules (
+  id       SERIAL PRIMARY KEY,
+  name     TEXT,
+  type     TEXT,
+  priority INTEGER NOT NULL DEFAULT 3,
+  price    NUMERIC(15,5),
+  discount NUMERIC(15,5),
+  obsolete BOOLEAN NOT NULL DEFAULT FALSE,
+  itime    TIMESTAMP,
+  mtime    TIMESTAMP
+);
+
+CREATE TABLE price_rule_items (
+  id                         SERIAL PRIMARY KEY,
+  price_rules_id             INTEGER NOT NULL,
+  type                       TEXT,
+  op                         TEXT,
+  custom_variable_configs_id INTEGER,
+  value_text                 TEXT,
+  value_int                  INTEGER,
+  value_date                 DATE,
+  value_num                  NUMERIC(15,5),
+  itime                      TIMESTAMP,
+  mtime                      TIMESTAMP,
+  FOREIGN KEY (price_rules_id) REFERENCES price_rules (id),
+  FOREIGN KEY (custom_variable_configs_id) REFERENCES custom_variable_configs (id)
+);
+
+CREATE TRIGGER mtime_price_rules BEFORE UPDATE ON price_rules FOR EACH ROW EXECUTE PROCEDURE set_mtime();
+CREATE TRIGGER mtime_price_rule_items BEFORE UPDATE ON price_rule_items FOR EACH ROW EXECUTE PROCEDURE set_mtime();
