From: Jess Robinson Date: Sat, 29 Apr 2006 19:38:43 +0000 (+0000) Subject: Default to using sqlt on deploy, if available X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0382d607b0059b43ff97286a00b9a9dede36834f;p=dbsrgits%2FDBIx-Class-Historic.git Default to using sqlt on deploy, if available --- diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index dcc4177..cee1c17 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -772,20 +772,24 @@ sub deployment_statements { $type ||= $self->sqlt_type; $version ||= $schema->VERSION || '1.x'; $dir ||= './'; -# eval "use SQL::Translator"; -# $self->throw_exception("Can't deploy without SQL::Translator: $@") if $@; -# eval "use SQL::Translator::Parser::DBIx::Class;"; -# $self->throw_exception($@) if $@; -# eval "use SQL::Translator::Producer::${type};"; -# $self->throw_exception($@) if $@; -# my $tr = SQL::Translator->new(%$sqltargs); -# SQL::Translator::Parser::DBIx::Class::parse( $tr, $schema ); -# return "SQL::Translator::Producer::${type}"->can('produce')->($tr); + eval "use SQL::Translator"; + if(!$@) + { + eval "use SQL::Translator::Parser::DBIx::Class;"; + $self->throw_exception($@) if $@; + eval "use SQL::Translator::Producer::${type};"; + $self->throw_exception($@) if $@; + my $tr = SQL::Translator->new(%$sqltargs); + SQL::Translator::Parser::DBIx::Class::parse( $tr, $schema ); + return "SQL::Translator::Producer::${type}"->can('produce')->($tr); + } my $filename = $schema->ddl_filename($type, $dir, $version); if(!-f $filename) { - $schema->create_ddl_dir([ $type ], $version, $dir, $sqltargs); +# $schema->create_ddl_dir([ $type ], $version, $dir, $sqltargs); + $self->throw_exception("No SQL::Translator, and no Schema file found, aborting deploy"); + return; } my $file; open($file, "<$filename")