X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FDeploymentHandler%2FDeployMethod%2FSQL%2FTranslator%2FScriptHelpers.pm;h=77d52accb08e6a57533f1ec2018b09333a49b1ee;hb=ae521c5583a2dd44484d4c27cd6cf01cb066c838;hp=ee210fe0b704236a5c82608cda17899b2c8872ed;hpb=10557c5984171f198fc27443b2d2e7c8d8b6cf7e;p=dbsrgits%2FDBIx-Class-DeploymentHandler.git diff --git a/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator/ScriptHelpers.pm b/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator/ScriptHelpers.pm index ee210fe..77d52ac 100644 --- a/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator/ScriptHelpers.pm +++ b/lib/DBIx/Class/DeploymentHandler/DeployMethod/SQL/Translator/ScriptHelpers.pm @@ -8,6 +8,8 @@ use Sub::Exporter::Progressive -setup => { }; use List::Util 'first'; +use Text::Brew 'distance'; +use Try::Tiny; sub dbh { my ($code) = @_; @@ -43,6 +45,7 @@ sub schema_from_schema_loader { warn 'using "current" naming in a deployment script is begging for problems. Just Say No.' if $opts->{naming} eq 'current' || (ref $opts->{naming} eq 'HASH' && first { $_ eq 'current' } values %{$opts->{naming}}); + sub { my ($schema, $versions) = @_; @@ -55,7 +58,28 @@ sub schema_from_schema_loader { 'SHSchema::' . $count++, $opts, \@ci ); my $sl_schema = $new_schema->connect(@ci); - $code->($sl_schema, $versions) + try { + $code->($sl_schema, $versions) + } catch { + if (m/Can't find source for (.+?) at/) { + my @presentsources = map { + (distance($_, $1))[0] < 3 ? "$_ <== Possible Match\n" : "$_\n"; + } $sl_schema->sources; + + die <<"ERR"; +$_ +You are seeing this error because the DBIx::Class::ResultSource in your +migration script called "$1" is not part of the schema that ::Schema::Loader +has inferred from your existing database. + +To help you debug this issue, here's a list of the actual sources that the +schema available to your migration knows about: + + @presentsources +ERR + } + die $_; + } } }