#!/bin/ksh
#
#  Rework anchoring flags, rename endpoint.pickup_only_enabled
#  Tied to build -18 , CR367
#

# migrate
#  $1 - absolute path 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
  update endpoint set status_tracking_enabled = 'N';
  update endpoint set status_tracking_enabled = 'Y' where
					endpoint_id in (select endpoint_id
									from status_subscription);
  exit;

EOF

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

esac
