From 8a05b49d59cf0a39a52764884e7ada413fa83c60 Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Fri, 22 Jan 2016 10:37:09 +0100 Subject: [PATCH] Feature #4305: Accelerate database conversion to ludicrous speed (cherry picked from commit 14a9ec048e3787e9151d1193e913798b91c1de3d) --- src/onedb/sqlite2mysql.rb | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/onedb/sqlite2mysql.rb b/src/onedb/sqlite2mysql.rb index 3b5ec585a4..c893e6357c 100644 --- a/src/onedb/sqlite2mysql.rb +++ b/src/onedb/sqlite2mysql.rb @@ -11,21 +11,22 @@ module Sqlite2MySQL records = sqlite_db[table].count puts "> #{table} (#{records} records)" - i=0 - sqlite_db[table].each do |row| - @db[table].insert(row) + @db.transaction do + i=0 + sqlite_db[table].each do |row| + @db[table].insert(row) - i+=1 - if i % PROGRESS == 0 - if i < PROGRESS+1 - print " #{i}" - else - print "...#{i}" + i+=1 + if i % PROGRESS == 0 + if i < PROGRESS+1 + print " #{i}" + else + print "...#{i}" + end end end + puts if i > PROGRESS-1 end - - puts if i > PROGRESS-1 end puts "\nMigration successful."