Yay, test passes!
[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__->belongs_to('created', 'DBIx::Class::Schema::Journal::DB::Change', 'create_id');
23   __PACKAGE__->belongs_to('deleted', 'DBIx::Class::Schema::Journal::DB::Change', 'delete_id');
24
25 sub new
26 {
27     my ($self, $data, @rest) = @_;
28     my $source = $data->{-result_source};
29
30     $data->{created} = { 
31 #        ID => \'DEFAULT',
32 #        ID => 1,
33         changeset_id => $source->schema->current_changeset,
34         %{$data->{created}}, 
35     };
36
37     $self->next::method($data, @rest);
38 }                           
39
40 1;