From d73d349d6fdbaa76a747ebdeacab54a5813cb718 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Fri, 21 Dec 2012 13:51:26 +0100 Subject: [PATCH] Feature #1326: onedb migrator adds template attribute TEMPLATE_NAME --- src/onedb/3.8.1_to_3.9.80.rb | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/onedb/3.8.1_to_3.9.80.rb b/src/onedb/3.8.1_to_3.9.80.rb index 6c4f489615..afe86b2a35 100644 --- a/src/onedb/3.8.1_to_3.9.80.rb +++ b/src/onedb/3.8.1_to_3.9.80.rb @@ -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