print STDERR "Schema: ", ref($self->result_source->schema), "\n";
my $al = $self->result_source->schema->_journal_schema->resultset("${s_name}AuditLog");
$al->create({
- changeset => $self->result_source->schema->_journal_schema->current_changeset(),
+# created => {
+# changeset => $self->result_source->schema->_journal_schema->current_changeset(),
+# },
});
}
__PACKAGE__->mk_classdata('journal_user'); ## [ class, field for user id ]
__PACKAGE__->mk_classdata('_journal_schema');
+sub throw_exception
+{
+}
+
+sub exception_action
+{
+ my $self = shift;
+ print STDERR Carp::longmess;
+
+ $self->next::method(@_);
+}
+
sub connection
{
my $self = shift;
## Create a new changeset, then run $code as a transaction
my $cs = $self->_journal_schema->resultset('ChangeSet');
- my $changeset = $cs->create({
- user_id => $self->_journal_schema->current_user(),
+ 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(),
});
$self->_journal_schema->current_changeset($changeset->ID);
{
my ($self, $data, @rest) = @_;
- $data->{change} = {
- changeset_id => $self->result_source->schema->_journal_schema->current_changeset,
+ $data->{change} = {
+# ID => \'DEFAULT',
+ changeset_id => $source->schema->current_changeset,
+ %{$data->{created}},
};
$self->next::method($data, @rest);
{
my ($self, $data, $source, @rest) = @_;
- $data->{created} = {
+ $data->{created} = {
+# ID => \'DEFAULT',
changeset_id => $source->schema->current_changeset,
+ %{$data->{created}},
};
$self->next::method($data, $source, @rest);
isa_ok($schema->_journal_schema->source('ArtistAuditLog'), 'DBIx::Class::ResultSource', 'ArtistAuditLog source exists');
my $new_cd = $schema->txn_do( sub {
+ my $artist = $schema->resultset('Artist')->create({
+ name => 'Fred Bloggs',
+ });
return $schema->resultset('CD')->create({
title => 'Angry young man',
- artist => 0,
+ artist => $artist,
year => 2000,
});
});
my $dbpass = $ENV{"DBICTEST_DBPASS"} || '';
my $schema = DBICTest::Schema->compose_connection('DBICTest' => $dsn, $dbuser, $dbpass);
- $schema->storage->on_connect_do(['PRAGMA synchronous = OFF']);
+# $schema->storage->on_connect_do(['PRAGMA synchronous = OFF']);
if ( !$args{no_deploy} ) {
__PACKAGE__->deploy_schema( $schema );
__PACKAGE__->populate_schema( $schema ) if( !$args{no_populate} );