From 23e12b997a58d9ceebca9f218d41105425bdcc11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Fri, 2 Sep 2011 12:02:07 +0200 Subject: [PATCH] Bug #772: onedb upgrade now counts the number of used leases --- src/onedb/2.0_to_2.9.80.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/onedb/2.0_to_2.9.80.rb b/src/onedb/2.0_to_2.9.80.rb index 01054ecb4d..20d47aeb62 100644 --- a/src/onedb/2.0_to_2.9.80.rb +++ b/src/onedb/2.0_to_2.9.80.rb @@ -256,10 +256,16 @@ module Migrator group = (uid == 0) ? "oneadmin" : "users" public = row[:public] + total_leases = 0 + @db.fetch("SELECT COUNT (ip) FROM old_leases WHERE (oid=#{oid} AND used=1)") do |r| + total_leases = r[:"COUNT (ip)"] + end + + # is stored in the DB, but it is not used to rebuild # the VirtualNetwork object, and it is generated each time the # network is listed. So setting it to 0 is safe - body = "#{oid}#{uid}#{gid}#{get_username(uid)}#{group}#{name}#{row[:type]}#{row[:bridge]}#{public}0#{row[:template]}" + body = "#{oid}#{uid}#{gid}#{get_username(uid)}#{group}#{name}#{row[:type]}#{row[:bridge]}#{public}#{total_leases}#{row[:template]}" @db[:network_pool].insert( :oid => oid,