Added helpful logging for the schema_from_schema_loader ScriptHelper
Arthur Axel 'fREW' Schmidt [Fri, 3 Aug 2012 01:41:50 +0000 (20:41 -0500)]
Changes
lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator/ScriptHelpers.pm

diff --git a/Changes b/Changes
index 0e836a3..f877f77 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,6 +1,7 @@
 Revision history for {{$dist->name}}
 
 {{$NEXT}}
+       - Added helpful logging for the schema_from_schema_loader ScriptHelper
        - Added much more helpful error for "Can't find source for..." error in
          migration scripts, based on code from DBIx::Class::Migration
        - Test suite now is fully parallelizable
index 77d52ac..622dc29 100644 (file)
@@ -10,6 +10,7 @@ use Sub::Exporter::Progressive -setup => {
 use List::Util 'first';
 use Text::Brew 'distance';
 use Try::Tiny;
+use DBIx::Class::DeploymentHandler::LogImporter qw(:dlog);
 
 sub dbh {
    my ($code) = @_;
@@ -46,6 +47,9 @@ sub schema_from_schema_loader {
       if $opts->{naming} eq 'current' ||
         (ref $opts->{naming} eq 'HASH' && first { $_ eq 'current' } values %{$opts->{naming}});
 
+   $opts->{debug} = 1
+      if !exists $opts->{debug} && $ENV{DBICDH_TRACE};
+
    sub {
       my ($schema, $versions) = @_;
 
@@ -57,6 +61,10 @@ sub schema_from_schema_loader {
       my $new_schema = DBIx::Class::Schema::Loader::make_schema_at(
         'SHSchema::' . $count++, $opts, \@ci
       );
+
+      Dlog_debug {
+         "schema_from_schema_loader generated the following sources: $_"
+      } [ $new_schema->sources ];
       my $sl_schema = $new_schema->connect(@ci);
       try {
          $code->($sl_schema, $versions)