Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 4f15333b

Von Moritz Bunkus vor fast 12 Jahren hinzugefügt

  • ID 4f15333b8cc0ae1b0b4089adc2e516ba002b298b
  • Vorgänger b810b2e9
  • Nachfolger dd6282f6

Fremdschlüssel für Tabellen oe, delivery_orders, parts, translation

Unterschiede anzeigen:

SL/DB/DeliveryOrder.pm
15 15
                                                    column_map   => { id => 'delivery_order_id' },
16 16
                                                    manager_args => { with_objects => [ 'parts' ] }
17 17
                                                  },
18
                                    shipto => { type       => 'one to one',
19
                                                class      => 'SL::DB::Shipto',
20
                                                column_map => { shipto_id => 'shipto_id' },
21
                                              },
22
                                    department => { type       => 'one to one',
23
                                                    class      => 'SL::DB::Department',
24
                                                    column_map => { department_id => 'id' },
25
                                                  },
26 18
                                   );
27 19

  
28 20
__PACKAGE__->meta->initialize;
SL/DB/MetaSetup/DeliveryOrder.pm
57 57
      key_columns => { customer_id => 'id' },
58 58
    },
59 59

  
60
    department => {
61
      class       => 'SL::DB::Department',
62
      key_columns => { department_id => 'id' },
63
    },
64

  
60 65
    employee => {
61 66
      class       => 'SL::DB::Employee',
62 67
      key_columns => { employee_id => 'id' },
......
77 82
      key_columns => { salesman_id => 'id' },
78 83
    },
79 84

  
85
    shipto => {
86
      class       => 'SL::DB::Shipto',
87
      key_columns => { shipto_id => 'shipto_id' },
88
    },
89

  
80 90
    vendor => {
81 91
      class       => 'SL::DB::Vendor',
82 92
      key_columns => { vendor_id => 'id' },
SL/DB/MetaSetup/Order.pm
28 28
    quonumber               => { type => 'text' },
29 29
    cusordnumber            => { type => 'text' },
30 30
    intnotes                => { type => 'text' },
31
    department_id           => { type => 'integer', default => '0' },
31
    department_id           => { type => 'integer' },
32 32
    itime                   => { type => 'timestamp', default => 'now()' },
33 33
    mtime                   => { type => 'timestamp' },
34 34
    shipvia                 => { type => 'text' },
......
53 53
  allow_inline_column_values => 1,
54 54

  
55 55
  foreign_keys => [
56
    contact => {
57
      class       => 'SL::DB::Contact',
58
      key_columns => { cp_id => 'cp_id' },
59
    },
60

  
56 61
    customer => {
57 62
      class       => 'SL::DB::Customer',
58 63
      key_columns => { customer_id => 'id' },
59 64
    },
60 65

  
66
    delivery_customer => {
67
      class       => 'SL::DB::Customer',
68
      key_columns => { delivery_customer_id => 'id' },
69
    },
70

  
71
    delivery_vendor => {
72
      class       => 'SL::DB::Vendor',
73
      key_columns => { delivery_vendor_id => 'id' },
74
    },
75

  
76
    department => {
77
      class       => 'SL::DB::Department',
78
      key_columns => { department_id => 'id' },
79
    },
80

  
61 81
    employee => {
62 82
      class       => 'SL::DB::Employee',
63 83
      key_columns => { employee_id => 'id' },
64 84
    },
65 85

  
86
    employee_obj => {
87
      class       => 'SL::DB::Employee',
88
      key_columns => { employee_id => 'id' },
89
    },
90

  
66 91
    globalproject => {
67 92
      class       => 'SL::DB::Project',
68 93
      key_columns => { globalproject_id => 'id' },
69 94
    },
70 95

  
96
    language => {
97
      class       => 'SL::DB::Language',
98
      key_columns => { language_id => 'id' },
99
    },
100

  
101
    payment => {
102
      class       => 'SL::DB::PaymentTerm',
103
      key_columns => { payment_id => 'id' },
104
    },
105

  
71 106
    salesman => {
72 107
      class       => 'SL::DB::Employee',
73 108
      key_columns => { salesman_id => 'id' },
74 109
    },
75 110

  
111
    shipto => {
112
      class       => 'SL::DB::Shipto',
113
      key_columns => { shipto_id => 'shipto_id' },
114
    },
115

  
76 116
    vendor => {
77 117
      class       => 'SL::DB::Vendor',
78 118
      key_columns => { vendor_id => 'id' },
SL/DB/MetaSetup/Part.pm
60 60
      key_columns => { buchungsgruppen_id => 'id' },
61 61
    },
62 62

  
63
    partsgroup => {
64
      class       => 'SL::DB::PartsGroup',
65
      key_columns => { partsgroup_id => 'id' },
66
    },
67

  
68
    payment => {
69
      class       => 'SL::DB::PaymentTerm',
70
      key_columns => { payment_id => 'id' },
71
    },
72

  
73
    price_factor => {
74
      class       => 'SL::DB::PriceFactor',
75
      key_columns => { price_factor_id => 'id' },
76
    },
77

  
63 78
    unit_obj => {
64 79
      class       => 'SL::DB::Unit',
65 80
      key_columns => { unit => 'name' },
SL/DB/MetaSetup/Translation.pm
22 22
  primary_key_columns => [ 'id' ],
23 23

  
24 24
  allow_inline_column_values => 1,
25

  
26
  foreign_keys => [
27
    language => {
28
      class       => 'SL::DB::Language',
29
      key_columns => { language_id => 'id' },
30
    },
31
  ],
25 32
);
26 33

  
27 34
1;
SL/DB/Order.pm
31 31
    class                  => 'SL::DB::PeriodicInvoicesConfig',
32 32
    column_map             => { id => 'oe_id' },
33 33
  },
34
  payment_term => {
35
    type       => 'one to one',
36
    class      => 'SL::DB::PaymentTerm',
37
    column_map => { payment_id => 'id' },
38
  },
39
  contact      => {
40
    type       => 'one to one',
41
    class      => 'SL::DB::Contact',
42
    column_map => { cp_id => 'cp_id' },
43
  },
44
  shipto       => {
45
    type       => 'one to one',
46
    class      => 'SL::DB::Shipto',
47
    column_map => { shipto_id => 'shipto_id' },
48
  },
49
  department   => {
50
    type       => 'one to one',
51
    class      => 'SL::DB::Department',
52
    column_map => { department_id => 'id' },
53
  },
54
  language     => {
55
    type       => 'one to one',
56
    class      => 'SL::DB::Language',
57
    column_map => { language_id => 'id' },
58
  },
59 34
);
60 35

  
61 36
__PACKAGE__->meta->initialize;
62 37

  
63 38
# methods
64 39

  
65
sub items { goto &orderitems; }
40
sub items         { goto &orderitems; }
41
sub payment_terms { goto &payment;    }
66 42

  
67 43
sub type {
68 44
  my $self = shift;
SL/DB/Part.pm
21 21
    class        => 'SL::DB::Assembly',
22 22
    column_map   => { id => 'id' },
23 23
  },
24
  partsgroup                     => {
25
    type         => 'one to one',
26
    class        => 'SL::DB::PartsGroup',
27
    column_map   => { partsgroup_id => 'id' },
28
  },
29
  price_factor   => {
30
    type         => 'one to one',
31
    class        => 'SL::DB::PriceFactor',
32
    column_map   => { price_factor_id => 'id' },
33
  },
34 24
  prices         => {
35 25
    type         => 'one to many',
36 26
    class        => 'SL::DB::Price',
sql/Pg-upgrade2/oe_delivery_orders_foreign_keys.sql
1
-- @tag: oe_delivery_orders_foreign_keys
2
-- @description: Fremdschlüsseldefinitionen für oe und delivery_orders
3
-- @depends: release_3_0_0
4
-- @charset: utf-8
5
ALTER TABLE oe ALTER COLUMN department_id DROP DEFAULT;
6

  
7
UPDATE oe              SET cp_id                = NULL WHERE (cp_id                IS NOT NULL) AND (cp_id                NOT IN (SELECT cp_id     FROM contacts));
8
UPDATE oe              SET delivery_customer_id = NULL WHERE (delivery_customer_id IS NOT NULL) AND (delivery_customer_id NOT IN (SELECT id        FROM customer));
9
UPDATE oe              SET delivery_vendor_id   = NULL WHERE (delivery_vendor_id   IS NOT NULL) AND (delivery_vendor_id   NOT IN (SELECT id        FROM vendor));
10
UPDATE oe              SET department_id        = NULL WHERE (department_id        IS NOT NULL) AND (department_id        NOT IN (SELECT id        FROM department));
11
UPDATE oe              SET language_id          = NULL WHERE (language_id          IS NOT NULL) AND (language_id          NOT IN (SELECT id        FROM language));
12
UPDATE oe              SET payment_id           = NULL WHERE (payment_id           IS NOT NULL) AND (payment_id           NOT IN (SELECT id        FROM payment_terms));
13
UPDATE oe              SET shipto_id            = NULL WHERE (shipto_id            IS NOT NULL) AND (shipto_id            NOT IN (SELECT shipto_id FROM shipto));
14

  
15
UPDATE delivery_orders SET department_id        = NULL WHERE (department_id        IS NOT NULL) AND (department_id        NOT IN (SELECT id        FROM department));
16
UPDATE delivery_orders SET shipto_id            = NULL WHERE (shipto_id            IS NOT NULL) AND (shipto_id            NOT IN (SELECT shipto_id FROM shipto));
17

  
18
ALTER TABLE oe              ADD FOREIGN KEY (cp_id)                REFERENCES contacts      (cp_id);
19
ALTER TABLE oe              ADD FOREIGN KEY (delivery_customer_id) REFERENCES customer      (id);
20
ALTER TABLE oe              ADD FOREIGN KEY (delivery_vendor_id)   REFERENCES vendor        (id);
21
ALTER TABLE oe              ADD FOREIGN KEY (department_id)        REFERENCES department    (id);
22
ALTER TABLE oe              ADD FOREIGN KEY (employee_id)          REFERENCES employee      (id);
23
ALTER TABLE oe              ADD FOREIGN KEY (language_id)          REFERENCES language      (id);
24
ALTER TABLE oe              ADD FOREIGN KEY (payment_id)           REFERENCES payment_terms (id);
25
ALTER TABLE oe              ADD FOREIGN KEY (shipto_id)            REFERENCES shipto        (shipto_id);
26

  
27
ALTER TABLE delivery_orders ADD FOREIGN KEY (department_id)        REFERENCES department    (id);
28
ALTER TABLE delivery_orders ADD FOREIGN KEY (shipto_id)            REFERENCES shipto        (shipto_id);
sql/Pg-upgrade2/parts_translation_foreign_keys.sql
1
-- @tag: parts_translation_foreign_keys
2
-- @description: Fremdschlüsseldefinitionen für parts, translation
3
-- @depends: release_3_0_0
4
-- @charset: utf-8
5

  
6
UPDATE parts SET partsgroup_id   = NULL WHERE (partsgroup_id   IS NOT NULL) AND (partsgroup_id   NOT IN (SELECT id FROM partsgroup));
7
UPDATE parts SET payment_id      = NULL WHERE (payment_id      IS NOT NULL) AND (payment_id      NOT IN (SELECT id FROM payment_terms));
8
UPDATE parts SET price_factor_id = NULL WHERE (price_factor_id IS NOT NULL) AND (price_factor_id NOT IN (SELECT id FROM price_factors));
9

  
10
ALTER TABLE parts ADD FOREIGN KEY (partsgroup_id)   REFERENCES partsgroup    (id);
11
ALTER TABLE parts ADD FOREIGN KEY (price_factor_id) REFERENCES price_factors (id);
12
ALTER TABLE parts ADD FOREIGN KEY (payment_id)      REFERENCES payment_terms (id);
13

  
14
ALTER TABLE translation ADD FOREIGN KEY (language_id) REFERENCES language (id);

Auch abrufbar als: Unified diff