our $VERSION = '0.900001_04';
$VERSION = eval $VERSION; # no errors in dev versions
-## On create/insert, add new entry to AuditLog
+## On create/insert, add new entry to AuditLog and new content to AuditHistory
sub _journal_schema {
my $self = shift;
sub insert {
my ($self, @args) = @_;
-
return if $self->in_storage;
my $res = $self->next::method(@args);
-
$self->journal_log_insert;
return $res;
}
}
-## On update, copy previous row's contents to AuditHistory
+## On update, copy row's new contents to AuditHistory
sub update {
my $self = shift;
- $self->journal_log_update(@_);
$self->next::method(@_);
+ $self->journal_log_update(@_);
}
sub journal_log_update {
my $self = shift;
- if($self->in_storage) {
+ if ($self->in_storage) {
my $j = $self->_journal_schema;
-
- my $change = $j->journal_create_change;
- my $prev = $self->result_source->resultset->find( $self->ident_condition );
- $j->journal_record_in_history( $prev, audit_change_id => $change );
+ my $change_id = $j->journal_create_change->id;
+ $j->journal_record_in_history( $self, audit_change_id => $change_id );
}
}
database. The storage object will be shared by the regular schema and the
journalling schema.
+=item journal_components @components
+
+If you want to add components to your journal
+(L<DBIx::Class::Schema::Versioned> for example) this would be the
+
+
=item journal_sources \@source_names
Set a list of source names you would like to audit, if unset, all