#!/bin/ksh
#
#  Add identity.timezone_name, device.origin with suitable defaults
#  Tied to build -129
#

# migrate
#  $1 - absolute patch to build.xml in test suite
#  $2 - phase
#     'before' - before loading
#     'migrate' - migrate data
#     'after' - after dump
#  returns - 0 success; 1 failure

#
# migration is to propagate domain type into endpoint type
# We need to have the constraint disabled because we can't
#  guarantee uniqueness and we don't want the insert to fail.  
#  At the end, we renable it as a test to test the data for after 
#  it's been inserted.

# We also need to return 1 if the migration has failed so the log
#  gets scanned.

case $2 in
	'before' | 'after')
		exit 0
		;;

	'migrate')
		dbLog=db_$$.log
		rm -f $dbLog
		echo "Testcase = $1" >$dbLog
		cat <<EOF | sqlplus $CSN_DBUSER/$CSN_DBUSER@$CSN_DBSERVICE >>$dbLog 2>&1
			alter table device modify origin default('AGENT_PROVIDED');
			alter table identity modify timezone_name default('DEFAULT');
		   exit;

EOF

		if [[ -z `grep ORA $dbLog` ]]
		then
			rm $dbLog
			exit 0
		else
			echo "log in `pwd`/$dbLog"
			exit 1
		fi
		;;

esac
