X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/deb4d2dbb676d7d6f69dfe7815d6e0cb09bd4a44..53593baa211863fbf66540cf1bcc36c8fb37257f:/sql/Pg-upgrade2/greetings_own_table.sql

diff --git a/sql/Pg-upgrade2/greetings_own_table.sql b/sql/Pg-upgrade2/greetings_own_table.sql
new file mode 100644
index 000000000..3921d571b
--- /dev/null
+++ b/sql/Pg-upgrade2/greetings_own_table.sql
@@ -0,0 +1,16 @@
+-- @tag: greetings_own_table
+-- @description: Eigene Tabelle fÃ¼r Anreden
+-- @depends: release_3_5_5
+
+CREATE TABLE greetings (
+  id          SERIAL,
+  description TEXT      NOT NULL,
+  PRIMARY KEY (id),
+  UNIQUE (description)
+);
+
+UPDATE customer SET greeting = trim(greeting) WHERE greeting NOT LIKE trim(greeting);
+UPDATE vendor   SET greeting = trim(greeting) WHERE greeting NOT LIKE trim(greeting);
+
+INSERT INTO greetings (description)
+  SELECT DISTINCT greeting FROM (SELECT greeting FROM customer UNION SELECT greeting FROM vendor) AS gr WHERE greeting IS NOT NULL AND greeting NOT LIKE '' ORDER BY greeting;
