use base qw/DBIx::Class::Storage::DBI/;
use mro 'c3';
-use POSIX 'strftime';
-use File::Copy;
-use File::Spec;
-
__PACKAGE__->sql_maker_class('DBIx::Class::SQLMaker::SQLite');
__PACKAGE__->sql_limit_dialect ('LimitOffset');
-sub backup
-{
+sub backup {
+
+ require File::Spec;
+ require File::Copy;
+ require POSIX;
+
my ($self, $dir) = @_;
$dir ||= './';
{
$dbname = $1 if($dsn =~ /^dbi:SQLite:(.+)$/i);
}
- $self->throw_exception("Cannot determine name of SQLite db file")
+ $self->throw_exception("Cannot determine name of SQLite db file")
if(!$dbname || !-f $dbname);
# print "Found database: $dbname\n";
# my $dbfile = file($dbname);
my ($vol, $dbdir, $file) = File::Spec->splitpath($dbname);
# my $file = $dbfile->basename();
- $file = strftime("%Y-%m-%d-%H_%M_%S", localtime()) . $file;
+ $file = POSIX::strftime("%Y-%m-%d-%H_%M_%S", localtime()) . $file;
$file = "B$file" while(-f $file);
mkdir($dir) unless -f $dir;
my $backupfile = File::Spec->catfile($dir, $file);
- my $res = copy($dbname, $backupfile);
+ my $res = File::Copy::copy($dbname, $backupfile);
$self->throw_exception("Backup failed! ($!)") if(!$res);
return $backupfile;
$self->next::method($schema, $type, $version, $dir, $sqltargs, @rest);
}
-sub datetime_parser_type { return "DateTime::Format::SQLite"; }
+sub datetime_parser_type { return "DateTime::Format::SQLite"; }
=head2 connect_call_use_foreign_keys