Revision 10348b51
Von Kivitendo Admin vor mehr als 8 Jahren hinzugefügt
SL/DB/Assembly.pm | ||
---|---|---|
7 | 7 |
|
8 | 8 |
use SL::DB::MetaSetup::Assembly; |
9 | 9 |
|
10 |
__PACKAGE__->meta->add_relationships( |
|
11 |
part => { |
|
12 |
type => 'many to one', |
|
13 |
class => 'SL::DB::Part', |
|
14 |
column_map => { parts_id => 'id' }, |
|
15 |
}, |
|
16 |
); |
|
17 |
|
|
18 | 10 |
# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all. |
19 | 11 |
__PACKAGE__->meta->make_manager_class; |
20 | 12 |
|
SL/DB/MetaSetup/Assembly.pm | ||
---|---|---|
11 | 11 |
__PACKAGE__->meta->columns( |
12 | 12 |
assembly_id => { type => 'serial', not_null => 1 }, |
13 | 13 |
bom => { type => 'boolean' }, |
14 |
id => { type => 'integer' }, |
|
14 |
id => { type => 'integer', not_null => 1 },
|
|
15 | 15 |
itime => { type => 'timestamp', default => 'now()' }, |
16 | 16 |
mtime => { type => 'timestamp' }, |
17 | 17 |
parts_id => { type => 'integer', not_null => 1 }, |
... | ... | |
23 | 23 |
__PACKAGE__->meta->allow_inline_column_values(1); |
24 | 24 |
|
25 | 25 |
__PACKAGE__->meta->foreign_keys( |
26 |
parts => { |
|
26 |
assembly_part => { |
|
27 |
class => 'SL::DB::Part', |
|
28 |
key_columns => { id => 'id' }, |
|
29 |
}, |
|
30 |
|
|
31 |
part => { |
|
27 | 32 |
class => 'SL::DB::Part', |
28 | 33 |
key_columns => { parts_id => 'id' }, |
29 | 34 |
}, |
scripts/rose_auto_create_model.pl | ||
---|---|---|
75 | 75 |
|
76 | 76 |
periodic_invoices_configs => { oe_id => 'order', email_recipient_contact_id => 'email_recipient_contact' }, |
77 | 77 |
reconciliation_links => { acc_trans_id => 'acc_trans' }, |
78 |
|
|
79 |
assembly => { parts_id => 'part', id => 'assembly_part' }, |
|
78 | 80 |
}, |
79 | 81 |
); |
80 | 82 |
|
sql/Pg-upgrade2/assembly_parts_foreign_key2.sql | ||
---|---|---|
1 |
-- @tag: assembly_parts_foreign_key2 |
|
2 |
-- @description: Erzeugnis erhält Fremdschlüssel auf parts + NOT NULL in Tabelle assembly |
|
3 |
-- @depends: assembly_parts_foreign_key |
|
4 |
-- @ignore: 0 |
|
5 |
|
|
6 |
ALTER TABLE assembly ADD FOREIGN KEY (id) REFERENCES parts(id); |
|
7 |
ALTER TABLE assembly ALTER COLUMN id SET NOT NULL; |
Auch abrufbar als: Unified diff
Erzeugnisfremdschlüssel auf Artikel 2
auch die Spalte id verlinken.
Die Tabelle assembly ist etwas Banane und nicht gerade Rose-freundlich.
Artikel eines Erzeugnisses haben den gleichen Eintrag in id.
Erzeugnisses ist.
Ein besserer Name für die Tabelle wäre assembly_items.