Merge branch 'b-3.6.1' of ../kivitendo-erp_20220811
[kivitendo-erp.git] / sql / Pg-upgrade2 / letter_cleanup.sql
diff --git a/sql/Pg-upgrade2/letter_cleanup.sql b/sql/Pg-upgrade2/letter_cleanup.sql
new file mode 100644 (file)
index 0000000..e87f6e0
--- /dev/null
@@ -0,0 +1,40 @@
+-- @tag: letter_cleanup
+-- @description: Tabelle »letter«: Unbenutzte Spalten entfernen und andere Spalten umbenennen
+-- @depends: release_3_4_0
+
+ALTER TABLE letter       RENAME COLUMN vc_id TO customer_id;
+ALTER TABLE letter_draft RENAME COLUMN vc_id TO customer_id;
+
+ALTER TABLE letter
+  DROP COLUMN close,
+  DROP COLUMN company_name,
+  DROP COLUMN employee_position,
+  DROP COLUMN jobnumber,
+  DROP COLUMN page_created_for,
+  DROP COLUMN rcv_address,
+  DROP COLUMN rcv_city,
+  DROP COLUMN rcv_contact,
+  DROP COLUMN rcv_country,
+  DROP COLUMN rcv_countrycode,
+  DROP COLUMN rcv_name,
+  DROP COLUMN rcv_zipcode,
+  DROP COLUMN salesman_position,
+  DROP COLUMN text_created_for,
+  ADD FOREIGN KEY (customer_id) REFERENCES customer (id);
+
+ALTER TABLE letter_draft
+  DROP COLUMN close,
+  DROP COLUMN company_name,
+  DROP COLUMN employee_position,
+  DROP COLUMN jobnumber,
+  DROP COLUMN page_created_for,
+  DROP COLUMN rcv_address,
+  DROP COLUMN rcv_city,
+  DROP COLUMN rcv_contact,
+  DROP COLUMN rcv_country,
+  DROP COLUMN rcv_countrycode,
+  DROP COLUMN rcv_name,
+  DROP COLUMN rcv_zipcode,
+  DROP COLUMN salesman_position,
+  DROP COLUMN text_created_for,
+  ADD FOREIGN KEY (customer_id) REFERENCES customer (id);