customer vendor in oe mit foreign keys sichern.
authorSven Schöling <s.schoeling@linet-services.de>
Fri, 30 Sep 2011 13:02:41 +0000 (15:02 +0200)
committerSven Schöling <s.schoeling@linet-services.de>
Tue, 4 Oct 2011 09:13:47 +0000 (11:13 +0200)
SL/DB/MetaSetup/Order.pm
sql/Pg-upgrade2/oe_customer_vendor_fkeys.sql [new file with mode: 0644]

index e616aa3..3595026 100644 (file)
@@ -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 (file)
index 0000000..0ac6c8b
--- /dev/null
@@ -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);