X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/deb4d2dbb676d7d6f69dfe7815d6e0cb09bd4a44..53593baa211863fbf66540cf1bcc36c8fb37257f:/sql/Pg-upgrade2/customer_additional_billing_addresses.sql?ds=sidebyside

diff --git a/sql/Pg-upgrade2/customer_additional_billing_addresses.sql b/sql/Pg-upgrade2/customer_additional_billing_addresses.sql
new file mode 100644
index 000000000..11fcfb033
--- /dev/null
+++ b/sql/Pg-upgrade2/customer_additional_billing_addresses.sql
@@ -0,0 +1,45 @@
+-- @tag: customer_additional_billing_addresses
+-- @description: Kundenstammdaten: zusÃ¤tzliche Rechnungsadressen
+-- @depends: release_3_5_8
+CREATE TABLE additional_billing_addresses (
+  id              SERIAL,
+  customer_id     INTEGER,
+  name            TEXT,
+  department_1    TEXT,
+  department_2    TEXT,
+  contact         TEXT,
+  street          TEXT,
+  zipcode         TEXT,
+  city            TEXT,
+  country         TEXT,
+  gln             TEXT,
+  email           TEXT,
+  phone           TEXT,
+  fax             TEXT,
+  default_address BOOLEAN NOT NULL DEFAULT FALSE,
+
+  itime           TIMESTAMP NOT NULL DEFAULT now(),
+  mtime           TIMESTAMP NOT NULL DEFAULT now(),
+
+  PRIMARY KEY (id),
+  FOREIGN KEY (customer_id) REFERENCES customer (id)
+);
+
+CREATE TRIGGER mtime_additional_billing_addresses
+BEFORE UPDATE ON additional_billing_addresses
+FOR EACH ROW EXECUTE PROCEDURE set_mtime();
+
+ALTER TABLE oe
+  ADD COLUMN billing_address_id INTEGER,
+  ADD FOREIGN KEY (billing_address_id)
+    REFERENCES additional_billing_addresses (id);
+
+ALTER TABLE delivery_orders
+  ADD COLUMN billing_address_id INTEGER,
+  ADD FOREIGN KEY (billing_address_id)
+    REFERENCES additional_billing_addresses (id);
+
+ALTER TABLE ar
+  ADD COLUMN billing_address_id INTEGER,
+  ADD FOREIGN KEY (billing_address_id)
+    REFERENCES additional_billing_addresses (id);
