PGDUMP=src/postgresql/src/bin/pg_dump/pg_dump
PGRESTORE=src/postgresql/src/bin/pg_dump/pg_restore

All: plain-dump-if-exists custom-dump custom-dump-if-exists-restore-if-exists

plain-dump-if-exists:
	-dropdb xx;
	createdb xx;
	psql xx -f dumptest.sql
	$(PGDUMP) xx --if-exists -c -f /tmp/xx_dump_if_exists.sql
	-dropdb yy
	createdb yy
	psql yy -f /tmp/xx_dump_if_exists.sql -v ON_ERROR_STOP=1
	psql yy -f /tmp/xx_dump_if_exists.sql -v ON_ERROR_STOP=1

custom-dump-if-exists-restore-if-exists:
	-dropdb xx;
	createdb xx;
	psql xx -f dumptest.sql
	$(PGDUMP) xx --if-exists -c -F c -f /tmp/xx_dump_if_exists.cdta
	-dropdb yy
	createdb yy
	$(PGRESTORE) /tmp/xx_dump_if_exists.cdta -d yy --exit-on-error -c --if-exists
	$(PGRESTORE) /tmp/xx_dump_if_exists.cdta -d yy --exit-on-error -c --if-exists

custom-dump:
	-dropdb xx;
	createdb xx;
	psql xx -f dumptest.sql
	$(PGDUMP) xx -F c -f /tmp/xx_dump.cdta
	-dropdb yy
	createdb yy
	$(PGRESTORE) /tmp/xx_dump.cdta -d yy  -c --if-exists --exit-on-error
	$(PGRESTORE) /tmp/xx_dump.cdta -d yy  -c --if-exists --exit-on-error
