my $db_file = "t/var/DBIxClass.db";
- unlink($db_file) if -e $db_file;
- unlink($db_file . "-journal") if -e $db_file . "-journal";
mkdir("t/var") unless -d "t/var";
+ if ( !$args{no_deploy} ) {
+ unlink($db_file) if -e $db_file;
+ unlink($db_file . "-journal") if -e $db_file . "-journal";
+ }
my $dsn = $args{"dsn"} || "dbi:SQLite:${db_file}";
my $dbuser = $args{"user"} || '';
my $self = shift;
my $schema = shift;
-
- my $file = $self->get_ddl_file($schema);
- open IN, $file;
+ my $file = shift || $self->get_ddl_file($schema);
+ open( my $fh, "<",$file ) or die "couldnt open $file, $!";
my $sql;
- { local $/ = undef; $sql = <IN>; }
- close IN;
- ($schema->storage->dbh->do($_) || print "Error on SQL: $_\n") for split(/;\n/, $sql);
+ { local $/ = undef; $sql = <$fh>; }
+
+ foreach my $line (split(/;\n/, $sql)) {
+ print "$line\n";
+ next if(!$line);
+ next if($line =~ /^--/);
+ next if($line =~ /^BEGIN TRANSACTION/m);
+ next if($line =~ /^COMMIT/m);
+ next if $line =~ /^\s+$/; # skip whitespace only
+
+ $schema->storage->dbh->do($line) || print "Error on SQL: $line\n";
+ }
}
[ 1, 'Caterwauler McCrae' ],
[ 2, 'Random Boy Band' ],
[ 3, 'We Are Goth' ],
+ [ 4, '' ], # Test overridden new will default name to "Test Name" using use_create => 1.
+ [ 32948, 'Big PK' ],
]);
$schema->populate('CD', [
[ 1, 1 ],
[ 1, 2 ],
[ 1, 3 ],
+ [ 2, 1 ],
+ [ 2, 2 ],
+ [ 3, 3 ],
]);
$schema->populate('Track', [