use SL::DB::MetaSetup::Assembly;
-__PACKAGE__->meta->add_relationships(
- part => {
- type => 'many to one',
- class => 'SL::DB::Part',
- column_map => { parts_id => 'id' },
- },
-);
-
# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all.
__PACKAGE__->meta->make_manager_class;
__PACKAGE__->meta->columns(
assembly_id => { type => 'serial', not_null => 1 },
bom => { type => 'boolean' },
- id => { type => 'integer' },
+ id => { type => 'integer', not_null => 1 },
itime => { type => 'timestamp', default => 'now()' },
mtime => { type => 'timestamp' },
parts_id => { type => 'integer', not_null => 1 },
__PACKAGE__->meta->allow_inline_column_values(1);
__PACKAGE__->meta->foreign_keys(
- parts => {
+ assembly_part => {
+ class => 'SL::DB::Part',
+ key_columns => { id => 'id' },
+ },
+
+ part => {
class => 'SL::DB::Part',
key_columns => { parts_id => 'id' },
},
periodic_invoices_configs => { oe_id => 'order', email_recipient_contact_id => 'email_recipient_contact' },
reconciliation_links => { acc_trans_id => 'acc_trans' },
+
+ assembly => { parts_id => 'part', id => 'assembly_part' },
},
);
--- /dev/null
+-- @tag: assembly_parts_foreign_key2
+-- @description: Erzeugnis erhält Fremdschlüssel auf parts + NOT NULL in Tabelle assembly
+-- @depends: assembly_parts_foreign_key
+-- @ignore: 0
+
+ALTER TABLE assembly ADD FOREIGN KEY (id) REFERENCES parts(id);
+ALTER TABLE assembly ALTER COLUMN id SET NOT NULL;