Tabelle parts: Fremdschlüssel für Konten
authorG. Richardson <information@kivitendo-premium.de>
Sat, 30 Jul 2016 07:38:46 +0000 (09:38 +0200)
committerG. Richardson <information@kivitendo-premium.de>
Sun, 31 Jul 2016 10:53:16 +0000 (12:53 +0200)
SL/DB/MetaSetup/Part.pm
sql/Pg-upgrade2/parts_add_chart_foreign_keys.sql [new file with mode: 0644]

index 392249d..c54a8cf 100644 (file)
@@ -66,6 +66,21 @@ __PACKAGE__->meta->foreign_keys(
     key_columns => { buchungsgruppen_id => 'id' },
   },
 
+  expense_accno => {
+    class       => 'SL::DB::Chart',
+    key_columns => { expense_accno_id => 'id' },
+  },
+
+  income_accno => {
+    class       => 'SL::DB::Chart',
+    key_columns => { income_accno_id => 'id' },
+  },
+
+  inventory_accno => {
+    class       => 'SL::DB::Chart',
+    key_columns => { inventory_accno_id => 'id' },
+  },
+
   partsgroup => {
     class       => 'SL::DB::PartsGroup',
     key_columns => { partsgroup_id => 'id' },
diff --git a/sql/Pg-upgrade2/parts_add_chart_foreign_keys.sql b/sql/Pg-upgrade2/parts_add_chart_foreign_keys.sql
new file mode 100644 (file)
index 0000000..97c4ae8
--- /dev/null
@@ -0,0 +1,8 @@
+-- @tag: parts_add_chart_foreign_keys
+-- @description: Warenkonten mit chart-Tabelle per Fremdschlüssel verknüpft.
+-- @depends: release_3_4_1
+-- @ignore: 0
+
+ALTER TABLE parts ADD FOREIGN KEY (income_accno_id)    REFERENCES chart(id);
+ALTER TABLE parts ADD FOREIGN KEY (inventory_accno_id) REFERENCES chart(id);
+ALTER TABLE parts ADD FOREIGN KEY (expense_accno_id)   REFERENCES chart(id);