Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 4766711a68
Fetching contributors…

Cannot retrieve contributors at this time

executable file 47 lines (44 sloc) 1.253 kb
#!/usr/bin/perl
use strict;
use warnings;
use FindBin;
$| = 1;
print "Initializing...";
use lib $FindBin::RealBin.'/../lib/';
# Lixuz doesn't like not being in its own dir when initializing
chdir($FindBin::RealBin.'/..');
require LIXUZ;
print "done\n";
sub migrateObject
{
my $object = shift;
my $new = shift;
my $t = 0;
while((defined $object) and my $o = $object->next)
{
$t++;
$o->set_column('folder_id',$new);
$o->update();
}
return $t;
}
foreach my $map (@ARGV)
{
(my $old = $map) =~ s/\D+\d+$//;
(my $new = $map) =~ s/^\d+\D+//;
my $oldF = LIXUZ->model('LIXUZDB::LzFolder')->find({folder_id => $old});
my $newF = LIXUZ->model('LIXUZDB::LzFolder')->find({folder_id => $new});
die if not $oldF;
die if not $newF;
print 'Moving ';
print $oldF->get_path.' ('.$old.')';
print ' to ';
print $newF->get_path.' ('.$new.')';
print "... ";
my $total = 0;
my $articles = LIXUZ->model('LIXUZDB::LzArticleFolder')->search({folder_id => $old});
$total += migrateObject($articles,$new);
my $files = LIXUZ->model('LIXUZDB::LzFile')->search({folder_id => $old});
$total += migrateObject($files,$new);
print "done - moved $total entries\n";
}
Jump to Line
Something went wrong with that request. Please try again.