Revision history for {{$dist->name}}
{{$NEXT}}
+ - preconnect should not connect to the database
0.001000_09 2010-05-15 23:19:05 CST6CDT
- Schemata is no longer required to add version checking component
my $fn = eval "$filedata";
use warnings;
- if ($@) {
+ if ($@) {
carp "$filename failed to compile: $@";
- } elsif (ref $fn eq 'CODE') {
+ } elsif (ref $fn eq 'CODE') {
$fn->($self->schema)
} else {
carp "$filename should define an anonymouse sub that takes a schema but it didn't!";
}
sub preinstall {
- my $self = shift;
- my $version = shift || $self->schema_version;
+ my $self = shift;
+ my $args = shift;
+ my $version = $args->{version} || $self->schema_version;
+ my $storage_type = $args->{storage_type} || $self->storage->sqlt_type;
my @files = @{$self->_ddl_preinstall_consume_filenames(
- $self->storage->sqlt_type,
+ $storage_type,
$version,
)};
if ( $filename =~ /^(.+)\.pl$/ ) {
my $filedata = do { local( @ARGV, $/ ) = $filename; <> };
- no warnings 'redefine';
+ no warnings 'redefine';
my $fn = eval "$filedata";
use warnings;
- if ($@) {
+ if ($@) {
carp "$filename failed to compile: $@";
- } elsif (ref $fn eq 'CODE') {
+ } elsif (ref $fn eq 'CODE') {
$fn->()
} else {
carp "$filename should define an anonymous sub but it didn't!";
--- /dev/null
+#!perl
+
+use strict;
+use warnings;
+
+use lib 't/lib';
+use DBICDHTest;
+use DBIx::Class::DeploymentHandler;
+use aliased 'DBIx::Class::DeploymentHandler', 'DH';
+
+use File::Path qw(remove_tree mkpath);
+use Test::More;
+use Test::Exception;
+
+DBICDHTest::ready;
+
+my $db = 'dbi:SQLite:db.db';
+my @connection = ($db, '', '', { ignore_version => 1, }, { on_connect_do => sub { die }});
+my $sql_dir = 't/sql';
+
+VERSION1: {
+ use_ok 'DBICVersion_v1';
+ my $s = DBICVersion::Schema->connect(@connection);
+ $DBICVersion::Schema::VERSION = 1;
+ ok($s, 'DBICVersion::Schema 1 instantiates correctly');
+ ok !$s->storage->connected, 'creating schema did not connect';
+ my $handler = DH->new({
+ upgrade_directory => $sql_dir,
+ schema => $s,
+ databases => 'SQLite',
+ sql_translator_args => { add_drop_table => 0 },
+ });
+ ok !$s->storage->connected, 'creating handler did not connect';
+ ok($handler, 'DBIx::Class::DeploymentHandler w/1 instantiates correctly');
+
+ mkpath('t/sql/SQLite/preinstall/1');
+ $handler->preinstall({ version => 1, storage_type => 'SQLite' });
+ ok !$s->storage->connected, 'creating schema did not connect';
+}
+done_testing;