#!/bin/sh
#
# Copyright (C) 2000-2015 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
#
# shell script to delete Bacula tables for PostgreSQL

bindir=@POSTGRESQL_BINDIR@
db_name=@db_name@

$bindir/psql -f - -d ${db_name} $* <<END-OF-DATA
drop table unsavedfiles;
drop table basefiles;
drop table jobmedia;
drop table file;
drop table job;
drop table jobhisto;
drop table media;
drop table client;
drop table pool;
drop table fileset;
drop table path;
drop table filename;
drop table counters;
drop table version;
drop table CDImages;
drop table Device;
drop table Storage;
drop table MediaType;
drop table Status;
drop table if exists MAC;
drop table log;
drop table Location;
drop table locationlog;
drop table PathVisibility;
drop table PathHierarchy;
drop table RestoreObject;
drop table Snapshot;
END-OF-DATA
pstat=$?
if test $pstat = 0; 
then
   echo "Deletion of Bacula PostgreSQL tables succeeded."
else
   echo "Deletion of Bacula PostgreSQL tables failed."
fi
exit $pstat
