Merge branch 'master' of github.com:kivitendo/kivitendo-erp
[kivitendo-erp.git] / SL / DB / MetaSetup / Project.pm
index 6b3ab91..5131535 100644 (file)
@@ -6,23 +6,36 @@ use strict;
 
 use base qw(SL::DB::Object);
 
-__PACKAGE__->meta->setup(
-  table   => 'project',
+__PACKAGE__->meta->table('project');
+
+__PACKAGE__->meta->columns(
+  active          => { type => 'boolean', default => 'true' },
+  customer_id     => { type => 'integer' },
+  description     => { type => 'text' },
+  id              => { type => 'integer', not_null => 1, sequence => 'id' },
+  itime           => { type => 'timestamp', default => 'now()' },
+  mtime           => { type => 'timestamp' },
+  project_type_id => { type => 'integer', not_null => 1 },
+  projectnumber   => { type => 'text' },
+  valid           => { type => 'boolean', default => 'true' },
+);
+
+__PACKAGE__->meta->primary_key_columns([ 'id' ]);
 
-  columns => [
-    id            => { type => 'integer', not_null => 1, sequence => 'id' },
-    projectnumber => { type => 'text' },
-    description   => { type => 'text' },
-    itime         => { type => 'timestamp', default => 'now()' },
-    mtime         => { type => 'timestamp' },
-    active        => { type => 'boolean', default => 'true' },
-  ],
+__PACKAGE__->meta->unique_keys([ 'projectnumber' ]);
 
-  primary_key_columns => [ 'id' ],
+__PACKAGE__->meta->allow_inline_column_values(1);
 
-  unique_key => [ 'projectnumber' ],
+__PACKAGE__->meta->foreign_keys(
+  customer => {
+    class       => 'SL::DB::Customer',
+    key_columns => { customer_id => 'id' },
+  },
 
-  allow_inline_column_values => 1,
+  project_type => {
+    class       => 'SL::DB::ProjectType',
+    key_columns => { project_type_id => 'id' },
+  },
 );
 
 1;