From: zby Date: Sat, 6 Feb 2010 19:15:37 +0000 (+0100) Subject: checking for table existande before adding add_drop_table X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=822c657c87b61b2fa41291924b49c2942cca7487;p=chaz%2Fp5-DBIx-Class-ResultSet-RecursiveUpdate checking for table existande before adding add_drop_table --- diff --git a/t/lib/DBSchema.pm b/t/lib/DBSchema.pm index e729155..9b1dca6 100644 --- a/t/lib/DBSchema.pm +++ b/t/lib/DBSchema.pm @@ -10,12 +10,21 @@ use DateTime; __PACKAGE__->load_namespaces( default_resultset_class => '+DBIx::Class::ResultSet::RecursiveUpdate' ); +sub tables_exist { + my ( $dsn, $user, $pass ) = @_; + my $dbh = DBI->connect($dsn, $user, $pass, ); + return $dbh->tables( '%', '%', 'dvd', ); +} + + sub get_test_schema { my ( $dsn, $user, $pass ) = @_; $dsn ||= 'dbi:SQLite:dbname=t/var/dvdzbr.db'; warn "testing $dsn"; my $schema = __PACKAGE__->connect( $dsn, $user, $pass, {} ); - $schema->deploy({ add_drop_table => 1, }); + my $deploy_attrs; + $deploy_attrs->{add_drop_table} = 1 if tables_exist( $dsn, $user, $pass ); + $schema->deploy( $deploy_attrs ); $schema->populate('User', [ [ qw/username name password / ], [ 'jgda', 'Jonas Alves', ''],