[Rt-commit] r17796 - in rt/3.999/trunk: .
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Sat Jan 17 06:00:32 EST 2009
Author: sunnavy
Date: Sat Jan 17 06:00:31 2009
New Revision: 17796
Modified:
rt/3.999/trunk/ (props changed)
rt/3.999/trunk/sbin/rt-migrate-db-from-3.8
Log:
r18859 at sunnavys-mb: sunnavy | 2009-01-17 17:08:46 +0800
refactor migrate db script to reduce memory usage
Modified: rt/3.999/trunk/sbin/rt-migrate-db-from-3.8
==============================================================================
--- rt/3.999/trunk/sbin/rt-migrate-db-from-3.8 (original)
+++ rt/3.999/trunk/sbin/rt-migrate-db-from-3.8 Sat Jan 17 06:00:31 2009
@@ -48,7 +48,7 @@
nick_name => 'nickname',
email_address => 'email',
principal_type => 'type',
- immediate_parent_id => 'immediate_parent'
+ immediate_parent_id => 'immediate_parent',
);
if ( $args{'db-type'} eq 'mysql' ) {
@@ -76,12 +76,13 @@
$run_sql->( '', "create database $tmp_rt3_db;\n" );
$run_sql->( $tmp_rt3_db, $dump_data );
- my $out =
-`mysqldump -u $args{'dba'} $tmp_rt3_db --complete-insert --no-create-info`;
- my @inserts = grep { /^INSERT INTO/ } split /\n/, $out;
- die "no inserts found" unless @inserts;
-
- for my $insert (@inserts) {
+ open my $fh, '-|',
+ "mysqldump -u $args{'dba'} $tmp_rt3_db --complete-insert --no-create-info"
+ or die $!;
+
+ while ( <$fh> ) {
+ next unless /^INSERT INTO/;
+ my $insert = $_;
# e.g. RT::Group -> RT::Model::Group
$insert =~ s/'RT::(?!System|ScripAction)(\w+)\b/'RT::Model::$1/g;
@@ -91,14 +92,13 @@
$insert =~ s/'AdminCc'/'admin_cc'/g;
$insert =~
s/(?<!INSERT INTO )`(\w+)`/'`' . ($name_changes{renaming( $1)} || renaming($1)) . '`'/ge;
+ $run_sql->( $args{'db-name-rt4'}, $insert );
}
- $run_sql->( $args{'db-name-rt4'}, @inserts );
+
$run_sql->( '', "drop database $tmp_rt3_db\n" );
# set up proper values for new added columns
# Queue.status_schema: 'default' # this is done automatically by rt4
-
-
}
# need to add a row for the default status schema in Attributes and update
More information about the Rt-commit
mailing list