warnings go byebye
[dbsrgits/DBIx-Class-Journal.git] / lib / DBIx / Class / Schema / Journal / DB / AuditLog.pm
1 package DBIx::Class::Schema::Journal::DB::AuditLog;
2
3 use base 'DBIx::Class::Schema::Journal::DB::Base';
4 __PACKAGE__->table(__PACKAGE__->table);
5
6 __PACKAGE__->add_columns(
7                            ID => {
8                                data_type => 'integer',
9 #                               is_auto_increment => 1,
10                                is_nullable => 0,
11                            },
12                            create_id => {
13                                data_type => 'integer',
14                                is_nullable => 0,
15                                is_foreign_key => 1,
16                            },
17                            delete_id => {
18                                data_type => 'integer',
19                                is_nullable => 1,
20                                is_foreign_key => 1,
21                            });
22 __PACKAGE__->set_primary_key('ID');
23
24   __PACKAGE__->belongs_to('created', 'DBIx::Class::Schema::Journal::DB::Change', 'create_id');
25   __PACKAGE__->belongs_to('deleted', 'DBIx::Class::Schema::Journal::DB::Change', 'delete_id');
26
27 sub new
28 {
29     my ($self, $data, @rest) = @_;
30     my $source = $data->{-result_source};
31
32     $data->{created} = { 
33 #        ID => \'DEFAULT',
34 #        ID => 1,
35         changeset_id => $source->schema->current_changeset,
36         %{$data->{created}||{}}, 
37     };
38
39     $self->next::method($data, @rest);
40 }                           
41
42 1;