From 822c657c87b61b2fa41291924b49c2942cca7487 Mon Sep 17 00:00:00 2001 From: zby Date: Sat, 6 Feb 2010 20:15:37 +0100 Subject: [PATCH] checking for table existande before adding add_drop_table --- t/lib/DBSchema.pm | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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', ''], -- 2.45.2