j0ey.de wrote:
is this Howto suitable for 3.6.3?
It's what I based my move on, however, I did end up with some extra
hackery to get it to work properly, including extra indexes but that's
something I'm told should be evaluated on a "per DB" basis, and I
suspect ours is nothing like yours.
Rather than using the SQL they provided I just took it straight from the
RT install process.
The mysql2pg script it's self works, however you'll probably need to
update the table names.
I ended up creating a dedicated MySQL slave that I would run the test
migration/upgrade off. This meant that I could stop the replication and
have a static content while testing.
And as Jesse mentions on the Wiki, Binary attachments get messed up, It
took me a while to realize why my database had dropped from 10 Gig to 1 Gig.
Attached is the script I used to fix the attachments. It comes with the
standard "worked for me" disclaimer. I also had a modification in
Attachments_Local.pm to make ContentEncoding, and Content Writable.
# {{{ sub _LocalAccessible
sub _LocalAccessible {
{
Content => { 'read'=>1, 'write' => 1 },
ContentEncoding => { 'read'=>1, 'write' => 1 },
};
}
# }}}
If I understand one of Jesse's earlier messages correctly you could
probably add the following to my script.
{
no warnings qw/redefine/;
use RT::Attachment;
sub RT::Attachment::_LocalAccessible {
{
Content => { 'read'=>1, 'write' => 1 },
ContentEncoding => { 'read'=>1, 'write' => 1 },
};
}
}
Mark
--
Mark Chappell
Unix Systems Administrator
#!/usr/bin/perl -w
############################################################################
# #
# mysql2pg.pl - Helps migration of RT database from MySQL to PostgreSQL #
# Copyright (C) 2007 - Gilmar Santos Jr #
# #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation; either version 2 of the License. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program; if not, write to the Free Software #
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, #
# MA 02110-1301, USA #
# #
# Gilmar Santos Jr - [EMAIL PROTECTED] #
# #
############################################################################
use strict;
use DBI;
use Data::Dumper;
use lib ("/etc/request-tracker3.6", "/usr/share/request-tracker3.6/lib",
"/usr/local/share/request-tracker3.6/lib");
use RT::Interface::CLI qw(CleanEnv GetCurrentUser);
use RT::Attachment;
CleanEnv();
RT::LoadConfig();
RT::Init();
$SIG{__DIE__} = "";
############# Adjust usernames and passwords!!!!!!! #############
my $mysql = DBI->connect("DBI:mysql:database=rt3:host=chas", "root", "mv920-h")
or die $DBI::errstr;
my @tables = (
'Attachments',
);
$| = 1;
foreach my $table (@tables) {
print "\rConverting $table... ";
my $nr_regs = $mysql->selectall_arrayref(
qq|SELECT count(*) FROM $table;|)->[0][0];
print "($nr_regs lines)\n";
my $data = $mysql->selectall_arrayref(
qq|SELECT * FROM $table ORDER BY ID DESC LIMIT
10000 OFFSET 0|,
{ Slice => {} } ) or die
$mysql->errstr;
my @keys = keys %{$data->[0]};
foreach my $reg (0 .. ($nr_regs - 1 > 9999 ? 9999 : $nr_regs - 1) ) {
my $Attachment = RT::Attachment->new($RT::SystemUser);
$Attachment->Load( $data->[$reg]->{'id'});
next if ( lc($data->[$reg]->{'ContentType'}) eq "text/plain");
my ($ContentEncoding, $Body) = $Attachment->_EncodeLOB(
$data->[$reg]->{'Content'}, $data->[$reg]->{'ContentType'});
my ($val, $msg) = $Attachment->SetContent( $Body );
print "\n *ERROR* $msg \n" unless ($val || $msg =~ /That is
already the current value/);
($val, $msg) = $Attachment->SetContentEncoding(
$ContentEncoding );
print "\n *ERROR* $msg \n" unless ($val || $msg =~ /That is
already the current value/);
print "\r (W) id " . $data->[$reg]->{'id'} . "
";
}
for (my $i = 10000; $i < $nr_regs; $i += 10000) {
print "\r (R)", sprintf('%10.2f', $i * 100 / $nr_regs), "\%
done ($i rows)";
$data = $mysql->selectall_arrayref(
qq|SELECT * FROM $table ORDER BY ID DESC LIMIT
10000 OFFSET $i|,
{ Slice => {} } ) or die $mysql->errstr;
print "\r (W)", sprintf('%10.2f', $i * 100 / $nr_regs), "\%
done ($i rows)";
foreach my $reg (0 .. ($nr_regs - $i > 9999 ? 9999 : $nr_regs -
$i - 1) ) {
my $Attachment = RT::Attachment->new($RT::SystemUser);
$Attachment->Load( $data->[$reg]->{'id'});
next if ( lc($data->[$reg]->{'ContentType'}) eq
"text/plain");
my ($ContentEncoding, $Body) = $Attachment->_EncodeLOB(
$data->[$reg]->{'Content'}, $data->[$reg]->{'ContentType'});
my ($val, $msg) = $Attachment->SetContent( $Body );
print "\n *ERROR* $msg \n" unless ($val || $msg =~
/That is already the current value/);
($val, $msg) = $Attachment->SetContentEncoding(
$ContentEncoding );
print "\n *ERROR* $msg \n" unless ($val || $msg =~
/That is already the current value/);
print "\r (W) id " . $data->[$reg]->{'id'} . "
" ;
}
}
}
$mysql->disconnect;
_______________________________________________
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users
Community help: http://wiki.bestpractical.com
Commercial support: [EMAIL PROTECTED]
Discover RT's hidden secrets with RT Essentials from O'Reilly Media.
Buy a copy at http://rtbook.bestpractical.com