1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

Bug #848: Take into account bug #871, avoid table lock

This commit is contained in:
Carlos Martín 2011-10-14 16:49:13 +02:00
parent 057e20531c
commit 9ed5b738a4

View File

@ -49,6 +49,8 @@ module Migrator
end
def check_names(table, elem)
@db.run "CREATE TABLE migrator_tmp (oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT);"
@db.fetch("SELECT * FROM #{table}") do |row|
if ( row[:name].length > 128 )
# Element name is bigger than 128 chars
@ -58,14 +60,23 @@ module Migrator
doc.root.each_element("NAME") { |e|
e.text = new_name
@db[table].filter(:oid => row[:oid]).update(
:name => new_name,
:body => doc.root.to_s)
}
@db[:migrator_tmp].insert(
:oid => row[:oid],
:name => new_name,
:body => doc.root.to_s)
puts " > #{elem} ##{row[:oid]} had a name bigger than 128 chars and has been renamed to #{new_name[0..10]}..."
end
end
@db.fetch("SELECT * FROM migrator_tmp") do |row|
@db[table].filter(:oid => row[:oid]).update(
:name => row[:name],
:body => row[:body])
end
@db.run "DROP TABLE migrator_tmp"
end
end