$self->throw_exception( "No audit_log entry found for ".ref($self) . " item $pri" ) if(!$alentry);
## bulk_update doesnt do "create new item on update of rel-accessor with hashref, yet
- my $change = $self->result_source->schema->_journal_schema->resultset('Change')->create({ changeset_id => $self->result_source->schema->_journal_schema->current_changeset });
- $alentry->delete_id($change->ID);
+ my $change = $self->result_source->schema->_journal_schema->resultset('ChangeLog')->create({ changeset_id => $self->result_source->schema->_journal_schema->current_changeset });
+ $alentry->delete_id($change->id);
$alentry->update();
}
}
__PACKAGE__->mk_group_accessors( simple => 'current_session' );
__PACKAGE__->mk_group_accessors( simple => '_current_changeset_container' );
+DBIx::Class::Schema::Journal::DB->load_classes(qw/
+ ChangeSet
+ ChangeLog
+ AuditLog
+ AuditHistory
+ /);
+
+
+sub _current_changeset {
+ my $self = shift;
+ my $ref = $self->_current_changeset_container;
+ $ref && $ref->{changeset};
+}
+
# this is for localization of the current changeset
sub current_changeset {
my ( $self, @args ) = @_;
- $self->throw_error("setting current_changeset is not supported, use txn_do to create a new changeset") if @args;
+ $self->throw_exception("setting current_changeset is not supported, use txn_do to create a new changeset") if @args;
- my $ref = $self->_current_changeset_container;
+ my $id = $self->_current_changeset;
- return $ref && $ref->{changeset};
-}
+ $self->throw_exception("Can't call current_changeset outside of a transaction") unless $id;
-DBIx::Class::Schema::Journal::DB->load_classes(qw/
- ChangeSet
- Change
- AuditLog
- AuditHistory
- /);
+ return $id;
+}
sub journal_create_changeset {
my ( $self, @args ) = @_;
data_type => 'integer',
is_nullable => 0,
});
-__PACKAGE__->belongs_to('change', 'DBIx::Class::Schema::Journal::DB::Change', 'change_id');
+__PACKAGE__->belongs_to('change', 'DBIx::Class::Schema::Journal::DB::ChangeLog', 'change_id');
sub new
{
});
__PACKAGE__->set_primary_key('ID');
- __PACKAGE__->belongs_to('created', 'DBIx::Class::Schema::Journal::DB::Change', 'create_id');
- __PACKAGE__->belongs_to('deleted', 'DBIx::Class::Schema::Journal::DB::Change', 'delete_id');
+ __PACKAGE__->belongs_to('created', 'DBIx::Class::Schema::Journal::DB::ChangeLog', 'create_id');
+ __PACKAGE__->belongs_to('deleted', 'DBIx::Class::Schema::Journal::DB::ChangeLog', 'delete_id');
sub new
{
-package DBIx::Class::Schema::Journal::DB::Change;
+package DBIx::Class::Schema::Journal::DB::ChangeLog;
use base 'DBIx::Class';
# __PACKAGE__->load_components(qw/Core/);
__PACKAGE__->load_components(qw/Ordered Core/);
-__PACKAGE__->table('change');
+__PACKAGE__->table('change_log');
__PACKAGE__->add_columns(
- ID => {
+ id => {
data_type => 'integer',
is_auto_increment => 1,
is_primary_key => 1,
);
-__PACKAGE__->set_primary_key('ID');
+__PACKAGE__->set_primary_key('id');
__PACKAGE__->add_unique_constraint('setorder', [ qw/changeset_id order_in/ ]);
__PACKAGE__->belongs_to('changeset', 'DBIx::Class::Schema::Journal::DB::ChangeSet', 'changeset_id');