Update example Result classes for proper DDL generation
[dbsrgits/DBIx-Class.git] / examples / Schema / MyApp / Schema / Result / Cd.pm
index 6d600a1..9b0602c 100644 (file)
@@ -3,14 +3,31 @@ package MyApp::Schema::Result::Cd;
 use warnings;
 use strict;
 
-use base qw/DBIx::Class::Core/;
+use base qw( DBIx::Class::Core );
 
 __PACKAGE__->table('cd');
 
-__PACKAGE__->add_columns(qw/ cdid artist title year /);
+__PACKAGE__->add_columns(
+  cdid => {
+    data_type => 'integer',
+    is_auto_increment => 1
+  },
+  artist => {
+    data_type => 'integer',
+  },
+  title => {
+    data_type => 'text',
+  },
+  year => {
+    data_type => 'datetime',
+    is_nullable => 1,
+  },
+);
 
 __PACKAGE__->set_primary_key('cdid');
 
+__PACKAGE__->add_unique_constraint([qw( title artist )]);
+
 __PACKAGE__->belongs_to('artist' => 'MyApp::Schema::Result::Artist');
 __PACKAGE__->has_many('tracks' => 'MyApp::Schema::Result::Track');