#!/bin/sh
#
# shell script to delete Bacula tables for PostgreSQL

bindir=@INGRES_BINDIR@
PATH="$bindir:$PATH"
db_name=${db_name:-@db_name@}
db_user=${db_user:-@db_user@}

sql -u${db_user} ${db_name} $* <<END-OF-DATA
DROP TABLE Filename;
DROP TABLE Path;
DROP TABLE File;
DROP TABLE RestoreObject;
DROP TABLE Job;
DROP TABLE JobHisto;
DROP TABLE Location;
DROP TABLE Fileset;
DROP TABLE JobMedia;
DROP TABLE Media;
DROP TABLE MediaType;
DROP TABLE Storage;
DROP TABLE Device;
DROP TABLE Pool;
DROP TABLE Client;
DROP TABLE Log;
DROP TABLE LocationLog;
DROP TABLE Counters;
DROP TABLE BaseFiles;
DROP TABLE UnsavedFiles;
DROP TABLE CDImages ;
DROP TABLE PathHierarchy;
DROP TABLE PathVisibility;
DROP TABLE Version;
DROP TABLE Status;
DROP SEQUENCE Filename_Seq;
DROP SEQUENCE Path_Seq;
DROP SEQUENCE File_Seq;
DROP SEQUENCE RestoreObject_Seq;
DROP SEQUENCE Job_Seq;
DROP SEQUENCE JobHisto_Seq;
DROP SEQUENCE Location_Seq;
DROP SEQUENCE Fileset_Seq;
DROP SEQUENCE JobMedia_Seq;
DROP SEQUENCE Media_Seq;
DROP SEQUENCE MediaType_Seq;
DROP SEQUENCE Storage_Seq;
DROP SEQUENCE Device_Seq;
DROP SEQUENCE Pool_Seq;
DROP SEQUENCE Client_Seq;
DROP SEQUENCE Log_Seq;
DROP SEQUENCE LocationLog_Seq;
DROP SEQUENCE BaseFiles_Seq;
\g
END-OF-DATA
pstat=$?
if test $pstat = 0; 
then
   echo "Deletion of Bacula Ingres tables succeeded."
else
   echo "Deletion of Bacula Ingres tables failed."
fi
exit $pstat
