From: Sven Schöling Date: Fri, 30 Sep 2011 13:02:41 +0000 (+0200) Subject: customer vendor in oe mit foreign keys sichern. X-Git-Tag: release-2.7.0beta1~254 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=51ff80116cec826a1d614dc10bc2f9b09a2b80cd;p=kivitendo-erp.git customer vendor in oe mit foreign keys sichern. --- diff --git a/SL/DB/MetaSetup/Order.pm b/SL/DB/MetaSetup/Order.pm index e616aa3d0..3595026b0 100644 --- a/SL/DB/MetaSetup/Order.pm +++ b/SL/DB/MetaSetup/Order.pm @@ -53,6 +53,11 @@ __PACKAGE__->meta->setup( allow_inline_column_values => 1, foreign_keys => [ + customer => { + class => 'SL::DB::Customer', + key_columns => { customer_id => 'id' }, + }, + employee => { class => 'SL::DB::Employee', key_columns => { employee_id => 'id' }, @@ -67,6 +72,11 @@ __PACKAGE__->meta->setup( class => 'SL::DB::Employee', key_columns => { salesman_id => 'id' }, }, + + vendor => { + class => 'SL::DB::Vendor', + key_columns => { vendor_id => 'id' }, + }, ], ); diff --git a/sql/Pg-upgrade2/oe_customer_vendor_fkeys.sql b/sql/Pg-upgrade2/oe_customer_vendor_fkeys.sql new file mode 100644 index 000000000..0ac6c8bf1 --- /dev/null +++ b/sql/Pg-upgrade2/oe_customer_vendor_fkeys.sql @@ -0,0 +1,11 @@ +-- @tag: oe_customer_vendor_fkeys +-- @encoding: utf-8 +-- @description: Foreign Keys für customer und vendor in oe +-- @depends: release_2_6_3 +-- @timestamp: 1317380460 +UPDATE oe SET customer_id = NULL WHERE customer_id = 0; +UPDATE oe SET vendor_id = NULL WHERE vendor_id = 0; + + +ALTER TABLE oe ADD FOREIGN KEY (customer_id) REFERENCES customer(id); +ALTER TABLE oe ADD FOREIGN KEY (vendor_id) REFERENCES vendor(id);