Revision d8381bdd
Von Kivitendo Admin vor mehr als 8 Jahren hinzugefügt
SL/DB/MetaSetup/Assembly.pm | ||
---|---|---|
14 | 14 |
id => { type => 'integer' }, |
15 | 15 |
itime => { type => 'timestamp', default => 'now()' }, |
16 | 16 |
mtime => { type => 'timestamp' }, |
17 |
parts_id => { type => 'integer' }, |
|
17 |
parts_id => { type => 'integer', not_null => 1 },
|
|
18 | 18 |
qty => { type => 'float', scale => 4 }, |
19 | 19 |
); |
20 | 20 |
|
... | ... | |
22 | 22 |
|
23 | 23 |
__PACKAGE__->meta->allow_inline_column_values(1); |
24 | 24 |
|
25 |
__PACKAGE__->meta->foreign_keys( |
|
26 |
parts => { |
|
27 |
class => 'SL::DB::Part', |
|
28 |
key_columns => { parts_id => 'id' }, |
|
29 |
}, |
|
30 |
); |
|
31 |
|
|
25 | 32 |
1; |
26 | 33 |
; |
sql/Pg-upgrade2/assembly_parts_foreign_key.sql | ||
---|---|---|
1 |
-- @tag: assembly_parts_foreign_key |
|
2 |
-- @description: Erzeugniselement (assembly) erhält Fremdschlüssel auf parts + NOT NULL |
|
3 |
-- @depends: release_3_4_1 |
|
4 |
-- @ignore: 0 |
|
5 |
|
|
6 |
ALTER TABLE assembly ADD FOREIGN KEY (parts_id) REFERENCES parts(id); |
|
7 |
ALTER TABLE assembly ALTER COLUMN parts_id SET NOT NULL; |
Auch abrufbar als: Unified diff
Erzeugnisfremdschlüssel auf Artikel
Tabelle assemblies mit parts verknüpfen