# Copyright (c) 2000, 2004 IBM Corp. - All Rights Reserved.
# IBM makes no representations or warranties about the suitability of
# this program, either express or implied, including but not limited to
# the implied warranties of merchantability, fitness for a particular
# purpose, or non-infringement. 
  
#!/bin/bash
# 
# # Copyright (c) 2000, 2004 IBM Corp. - All Rights Reserved.
# # IBM makes no representations or warranties about the suitability of
# # this program, either express or implied, including but not limited to
# # the implied warranties of merchantability, fitness for a particular
# # purpose, or non-infringement. 
# 
#


# and index was changed and there was not straight utility to recreate only the indexes


${ECHO}
${ECHO} "********************************************************"
${ECHO} "********************************************************"
${ECHO} "**"
${ECHO} "** You are about to run recreate_indexes"
${ECHO} "** This will take a long while if the database schema"
${ECHO} "** already has data"
${ECHO} "** All the indexes in the database will be dropped"
${ECHO} "** and recreated"
${ECHO} "**"
${ECHO} "********************************************************"
${ECHO} "********************************************************"
${ECHO}

. ${TOP}/src/db/schema/util/set_db.sh

${ECHO}
${ECHO} "********************************************************"
${ECHO} "********************************************************"
${ECHO} "**"
${ECHO} "** Please confirm one more time"
${ECHO} "**"
${ECHO} "********************************************************"
${ECHO} "********************************************************"
${ECHO}

. ${TOP}/src/db/schema/util/set_db.sh


cd $DB_ROOT_DIR/schema

DB_USER=`${ECHO} ${DB_USER_NAME} | ${TR} "[:lower:]" "[:upper:]"`
START_TIME=`date`

${ECHO}
${ECHO} =====================================================
${ECHO}   Index re-creation initiated. 
${ECHO}   Database Schema : $DB_USER
${ECHO} =====================================================



#
# Re-creating the indexes.

for FILE in `ls $TOP/src/db/schema/gen/idx*.sql 2>/dev/null`
do
${ECHO}
${ECHO} ====================================================
${ECHO} "Running SQL File for Index creation :"
${ECHO} " $FILE"
${ECHO} ====================================================
${ECHO}


. ${DB_DIR}/util/run_db_cmd.sh --file=$FILE --errorfilter=yes

done

END_TIME=`date`
${ECHO}
${ECHO} =====================================================
${ECHO}   Completed re-creation of indexes.
${ECHO}   Database Schema  : $DB_USER
${ECHO}   Start Time       : $START_TIME
${ECHO}   End Time         : $END_TIME
${ECHO} =====================================================
${ECHO}


