6a37d386a239b83c5a529a4454584270ec5d3887
[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_nullable => 0,
10                            },
11                            create_id => {
12                                data_type => 'integer',
13                                is_nullable => 0,
14                                is_foreign_key => 1,
15                            },
16                            delete_id => {
17                                data_type => 'integer',
18                                is_nullable => 1,
19                                is_foreign_key => 1,
20                            });
21   __PACKAGE__->belongs_to('created', 'DBIx::Class::Schema::Journal::DB::Change', 'create_id');
22   __PACKAGE__->belongs_to('deleted', 'DBIx::Class::Schema::Journal::DB::Change', 'delete_id');
23
24 sub new
25 {
26     my ($self, $data, @rest) = @_;
27
28     $data->{created} = {
29         changeset_id => $self->result_source->schema->_journal_schema->current_changeset,
30     };
31
32     $self->next::method($data, @rest);
33 }                           
34
35 1;