#!/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
#

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

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

if [ ! "x${PORT}" = "x" ]; then
	PORTARG="-p ${PORT}"
fi
PSQL="psql -X ${PORTARG} -d ${DBT2DBNAME}"

${PSQL} -c "DROP TABLE customer CASCADE;"
${PSQL} -c "DROP TABLE district CASCADE;"
${PSQL} -c "DROP TABLE history CASCADE;"
${PSQL} -c "DROP TABLE item CASCADE;"
${PSQL} -c "DROP TABLE new_order CASCADE;"
${PSQL} -c "DROP TABLE order_line CASCADE;"
${PSQL} -c "DROP TABLE orders CASCADE;"
${PSQL} -c "DROP TABLE stock CASCADE;"
${PSQL} -c "DROP TABLE warehouse CASCADE;"
