if($self->in_storage)
{
my $s_name = $self->result_source->source_name();
- print STDERR "Schema: ", ref($self->result_source->schema), "\n";
my $al = $self->result_source->schema->_journal_schema->resultset("${s_name}AuditLog");
+ my ($pri, $too_many) = map { $self->get_column($_)} $self->primary_columns;
+ if(defined $pri && defined $too_many)
+ {
+ $self->throw_exception( "More than one possible key found for auto-inc on ".ref $self );
+ }
+ $pri ||= \'NULL'; #'
$al->create({
+ ID => $pri,
# created => {
# changeset => $self->result_source->schema->_journal_schema->current_changeset(),
# },
sub exception_action
{
my $self = shift;
- print STDERR Carp::longmess;
+# print STDERR Carp::longmess;
$self->next::method(@_);
}
my $self = shift;
$self->next::method(@_);
- print STDERR join(":", $self->sources), "\n";
+# print STDERR join(":", $self->sources), "\n";
my $journal_schema = DBIx::Class::Schema::Journal::DB->connect(@{ $self->journal_connection || $self->storage->connect_info });
# print STDERR "conn", $journal_schema->storage->connect_info;
## Create a new changeset, then run $code as a transaction
my $cs = $self->_journal_schema->resultset('ChangeSet');
+
+ $self->txn_begin;
my $changeset = $cs->create({ ( $self->_journal_schema->current_user() ? ( user_id => $self->_journal_schema->current_user()) : () ),
# user_id => $self->_journal_schema->current_user(),
session_id => $self->_journal_schema->current_session(),
sub new
{
my ($self, $data, @rest) = @_;
+ my $source = $data->{-result_source};
$data->{change} = {
# ID => \'DEFAULT',
__PACKAGE__->add_columns(
ID => {
data_type => 'integer',
+# is_auto_increment => 1,
is_nullable => 0,
},
create_id => {
sub new
{
- my ($self, $data, $source, @rest) = @_;
+ my ($self, $data, @rest) = @_;
+ my $source = $data->{-result_source};
$data->{created} = {
# ID => \'DEFAULT',
+# ID => 1,
changeset_id => $source->schema->current_changeset,
%{$data->{created}},
};
- $self->next::method($data, $source, @rest);
+ $self->next::method($data, @rest);
}
1;
use base 'DBIx::Class';
+# __PACKAGE__->load_components(qw/Core/);
__PACKAGE__->load_components(qw/Ordered Core/);
__PACKAGE__->table('change');
__PACKAGE__->add_unique_constraint('setorder', [ qw/changeset_id order_in/ ]);
__PACKAGE__->belongs_to('changeset', 'DBIx::Class::Schema::Journal::DB::ChangeSet', 'changeset_id');
-__PACKAGE__->position_column('order_in');
-__PACKAGE__->grouping_column('changeset_id');
+ __PACKAGE__->position_column('order_in');
+ __PACKAGE__->grouping_column('changeset_id');
1;