Backups and Path::Class
Jess Robinson [Fri, 19 May 2006 08:38:07 +0000 (08:38 +0000)]
lib/DBIx/Class/Schema.pm
lib/DBIx/Class/Storage/DBI.pm

index 40caff6..8297e3f 100644 (file)
@@ -5,7 +5,7 @@ use warnings;
 
 use Carp::Clan qw/^DBIx::Class/;
 use Scalar::Util qw/weaken/;
-use File::Spec;
+use Path::Class;
 
 use base qw/DBIx::Class/;
 
@@ -785,11 +785,12 @@ format.
 
 sub ddl_filename
 {
-    my ($self, $dir, $type, $version) = @_;
+    my ($self, $dir, $type, $version, $pversion) = @_;
 
     my $filename = ref($self);
     $filename =~ s/^.*:://;
-    $filename = File::Spec->catpath($dir, "$filename-$version-$type.sql");
+    $filename = file($dir, "$filename-$version-$type.sql")->stringify;
+    $filename =~ s/$version/$pversion-$version/ if($pversion);
 
     return $filename;
 }
index 552794d..31b3ed8 100644 (file)
@@ -811,8 +811,7 @@ sub create_ddl_dir
                                                     $target_schema, $db,
                                                     {}
                                                    );
-      my $difffile = $filename;
-      $difffile =~ s/$version/${preversion}-${version}/;
+      my $difffile = $schema->ddl_filename($dir, $db, $version, $preversion);
       if(-e $difffile)
       {
         warn("$difffile already exists, skipping");
@@ -876,6 +875,13 @@ sub deploy {
   }
 }
 
+sub backup
+{
+  my ($self) = @_;
+
+  ## Does nothing, override in DBI::XX classes
+}
+
 sub DESTROY { shift->disconnect }
 
 1;