From: Jess Robinson Date: Wed, 22 Nov 2006 20:44:36 +0000 (+0000) Subject: Fix tests, remove some random rints X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e2c0df8e0b707050eb005ac6f68548f857a36acf;p=dbsrgits%2FDBIx-Class-Historic.git Fix tests, remove some random rints --- diff --git a/lib/DBIx/Class/Schema/Versioned.pm b/lib/DBIx/Class/Schema/Versioned.pm index ba38ad7..6ab73e4 100644 --- a/lib/DBIx/Class/Schema/Versioned.pm +++ b/lib/DBIx/Class/Schema/Versioned.pm @@ -54,6 +54,7 @@ sub on_connect my $vschema = DBIx::Class::Version->connect(@{$self->storage->connect_info()}); my $vtable = $vschema->resultset('Table'); my $pversion; + if(!$self->exists($vtable)) { # $vschema->storage->debug(1); @@ -193,6 +194,8 @@ sub run_upgrade return 1; } +1; + =head1 NAME DBIx::Class::Versioning - DBIx::Class::Schema plugin for Schema upgrades diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 4b63c4f..99896da 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -1153,7 +1153,7 @@ sub create_ddl_dir } my $prefilename = $schema->ddl_filename($db, $dir, $preversion); - print "Previous version $prefilename\n"; +# print "Previous version $prefilename\n"; if(!-e $prefilename) { warn("No previous schema file found ($prefilename)"); diff --git a/t/94versioning.t b/t/94versioning.t index 81245e2..1c8026c 100644 --- a/t/94versioning.t +++ b/t/94versioning.t @@ -20,28 +20,31 @@ unlink($db_file . "-journal") if -e $db_file . "-journal"; mkdir("t/var") unless -d "t/var"; unlink('t/var/DBICVersion-Schema-1.0-SQLite.sql'); -my $schema = DBICVersion::Schema->connect("dbi:SQLite:$db_file"); +my $schema_orig = DBICVersion::Schema->connect("dbi:SQLite:$db_file"); # $schema->storage->ensure_connected(); -is($schema->ddl_filename('SQLite', 't/var', '1.0'), 't/var/DBICVersion-Schema-1.0-SQLite.sql', 'Filename creation working'); -$schema->create_ddl_dir('SQLite', undef, 't/var'); +is($schema_orig->ddl_filename('SQLite', 't/var', '1.0'), 't/var/DBICVersion-Schema-1.0-SQLite.sql', 'Filename creation working'); +$schema_orig->create_ddl_dir('SQLite', undef, 't/var'); ok(-f 't/var/DBICVersion-Schema-1.0-SQLite.sql', 'Created DDL file'); ## do this here or let Versioned.pm do it? # $schema->deploy(); -my $tvrs = $schema->resultset('Table'); -is($schema->exists($tvrs), 1, 'Created schema from DDL file'); +my $tvrs = $schema_orig->resultset('Table'); +is($schema_orig->exists($tvrs), 1, 'Created schema from DDL file'); eval "use DBICVersionNew"; -my $schema2 = DBICVersion::Schema->connect("dbi:SQLite:$db_file"); +my $schema_new = DBICVersion::Schema->connect("dbi:SQLite:$db_file"); unlink('t/var/DBICVersion-Schema-2.0-SQLite.sql'); unlink('t/var/DBICVersion-Schema-1.0-2.0-SQLite.sql'); -$schema2->create_ddl_dir('SQLite', undef, 't/var', '1.0'); +$schema_new->create_ddl_dir('SQLite', undef, 't/var', '1.0'); ok(-f 't/var/DBICVersion-Schema-1.0-2.0-SQLite.sql', 'Created DDL upgrade file'); +## create new to pick up filedata for upgrade files we just made (on_connect) +my $schema_upgrade = DBICVersion::Schema->connect("dbi:SQLite:$db_file"); + ## do this here or let Versioned.pm do it? -$schema2->upgrade(); -$tvrs = $schema2->resultset('Table'); -is($schema2->exists($tvrs), 1, 'Upgraded schema from DDL file'); +$schema_upgrade->upgrade(); +$tvrs = $schema_upgrade->resultset('Table'); +is($schema_upgrade->exists($tvrs), 1, 'Upgraded schema from DDL file');