##
# Project: one.migration: Scripts for the migration from opennebula 1.4 to 2.0.1 
# Description:  This bash source file contains functions for the SQL migration.
#   
# @author Marlon Nerling, Abacus Research AG, 9301 Wittenbach, Schweiz http://www.abacus.ch Copyright (C) 2010.
#   
# @see The GNU Public License (GPL)
#
## 
# This program is free software; you can redistribute it and/or modify 
# it under the terms of the GNU General Public License as published by 
# the Free Software Foundation; either version 2 of the License, or 
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful, but 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
# for more details.
# 
# You should have received a copy of the GNU General Public License along 
# with this program; if not, write to the Free Software Foundation, Inc., 
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#

ORIGINAL_DB=${ORIGINAL_DB?"Variable ORIGINAL_DB may be set"}
ONEMIGRATION_COMMON=${ONEMIGRATION_COMMON?"ONEMIGRATION_COMMON source (one.migration.common.sh) was not sourced"}

history.fields(){
	echo 'vid,seq,host_name,vm_dir,hid,vm_mad,tm_mad,stime,etime,pstime,petime,rstime,retime,estime,eetime,reason'
}

unchanged.get_insert_text(){
	where_id=${1?"[FAIL]:$FUNCNAME waits for a id as first parameter"};shift
	table=${1?"[FAIL]:$FUNCNAME waits for a table as second parameter"};shift
	local values=`query_sqlite_prepare " SELECT * FROM $table WHERE $where_id ;"`	
	 echo "INSERT INTO $table VALUES ( $values );"
}

