#!/bin/sh

#
# This file is released under the terms of the Artistic License.
# Please see the file LICENSE, included in this package, for details.
#
# Copyright The DBT-2 Authors
#

while getopts "l:" OPT; do
	case ${OPT} in
	l)
		PORT=${OPTARG}
		;;
	\?)
		exit 1
		;;
	esac
done

if [ ! "${PORT}" = "" ]; then
	PORTARG="-p ${PORT}"
fi

if [ -z "${DBT2DBNAME}" ]; then
	echo "DBT2DBNAME not defined."
	exit 1
fi

PSQL="psql -X ${PORTARG} -e -d ${DBT2DBNAME}"

${PSQL} -c "
CREATE INDEX i_orders
ON orders (o_w_id, o_d_id, o_c_id);
" || exit 1

${PSQL} -c "
CREATE INDEX i_customer
ON customer (c_w_id, c_d_id, c_last, c_first, c_id);
" || exit 1

exit 0
