Feature #1326: onedb migrator adds template attribute TEMPLATE_NAME

This commit is contained in:
Carlos Martín committed 2012-12-21 13:51:26 +01:00
1 parent 8e80bfcf66
commit d73d349d6f
1 file changed
+28
+28
View File
@@ -259,6 +259,34 @@ module Migrator
@db.run "DROP TABLE old_group_pool;"
########################################################################
# Feature #1326
########################################################################
@db.run "ALTER TABLE template_pool RENAME TO old_template_pool;"
@db.run "CREATE TABLE template_pool (oid INTEGER PRIMARY KEY, name VARCHAR(128), body TEXT, uid INTEGER, gid INTEGER, owner_u INTEGER, group_u INTEGER, other_u INTEGER);"
@db.fetch("SELECT * FROM old_template_pool") do |row|
doc = Document.new(row[:body])
doc.root.each_element("TEMPLATE") { |e|
e.add_element("TEMPLATE_NAME").text = row[:name]
}
@db[:template_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
@db.run "DROP TABLE old_template_pool;"
########################################################################
#
# Banner for the new /var/lib/one/vms directory