From: G. Richardson Date: Fri, 3 Jun 2016 20:07:46 +0000 (+0200) Subject: Erzeugnisfremdschlüssel auf Artikel X-Git-Tag: release-3.5.4~2173 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=d8381bdd3ef4c781ac61dd259bd2b4677fecc5e6;p=kivitendo-erp.git Erzeugnisfremdschlüssel auf Artikel Tabelle assemblies mit parts verknüpfen --- diff --git a/SL/DB/MetaSetup/Assembly.pm b/SL/DB/MetaSetup/Assembly.pm index 51073406b..373f54e6b 100644 --- a/SL/DB/MetaSetup/Assembly.pm +++ b/SL/DB/MetaSetup/Assembly.pm @@ -14,7 +14,7 @@ __PACKAGE__->meta->columns( id => { type => 'integer' }, itime => { type => 'timestamp', default => 'now()' }, mtime => { type => 'timestamp' }, - parts_id => { type => 'integer' }, + parts_id => { type => 'integer', not_null => 1 }, qty => { type => 'float', scale => 4 }, ); @@ -22,5 +22,12 @@ __PACKAGE__->meta->primary_key_columns([ 'assembly_id' ]); __PACKAGE__->meta->allow_inline_column_values(1); +__PACKAGE__->meta->foreign_keys( + parts => { + class => 'SL::DB::Part', + key_columns => { parts_id => 'id' }, + }, +); + 1; ; diff --git a/sql/Pg-upgrade2/assembly_parts_foreign_key.sql b/sql/Pg-upgrade2/assembly_parts_foreign_key.sql new file mode 100644 index 000000000..8b3d4b260 --- /dev/null +++ b/sql/Pg-upgrade2/assembly_parts_foreign_key.sql @@ -0,0 +1,7 @@ +-- @tag: assembly_parts_foreign_key +-- @description: Erzeugniselement (assembly) erhält Fremdschlüssel auf parts + NOT NULL +-- @depends: release_3_4_1 +-- @ignore: 0 + +ALTER TABLE assembly ADD FOREIGN KEY (parts_id) REFERENCES parts(id); +ALTER TABLE assembly ALTER COLUMN parts_id SET NOT NULL;