mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
Feature #3782: Add image snapshot attributes in onedb upgrade
This commit is contained in:
parent
db017a470b
commit
9e24ff5a2e
@ -143,6 +143,34 @@ module Migrator
|
||||
|
||||
log_time()
|
||||
|
||||
# 3782
|
||||
|
||||
@db.run "ALTER TABLE image_pool RENAME TO old_image_pool;"
|
||||
@db.run "CREATE TABLE image_pool (oid INTEGER PRIMARY KEY, name VARCHAR(128), body MEDIUMTEXT, uid INTEGER, gid INTEGER, owner_u INTEGER, group_u INTEGER, other_u INTEGER, UNIQUE(name,uid) );"
|
||||
|
||||
@db.transaction do
|
||||
@db.fetch("SELECT * FROM old_image_pool") do |row|
|
||||
doc = Nokogiri::XML(row[:body],nil,NOKOGIRI_ENCODING){|c| c.default_xml.noblanks}
|
||||
|
||||
doc.root.add_child(doc.create_element("TARGET_SNAPSHOT")).content = "-1"
|
||||
doc.root.add_child(doc.create_element("SNAPSHOTS"))
|
||||
|
||||
@db[:image_pool].insert(
|
||||
:oid => row[:oid],
|
||||
:name => row[:name],
|
||||
:body => doc.root.to_s,
|
||||
:uid => row[:uid],
|
||||
:gid => row[:gid],
|
||||
:owner_u => row[:owner_u],
|
||||
:group_u => row[:group_u],
|
||||
:other_u => row[:other_u])
|
||||
end
|
||||
end
|
||||
|
||||
@db.run "DROP TABLE old_image_pool;"
|
||||
|
||||
log_time()
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user