When we come across scenarios whereby we have to drop all the tables in a database before a restore, the following commands come in handy.

DROP SCHEMA public CASCADE;
CREATE SCHEMA public;

GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO public;

To manually drop all tables in a database we

select ‘DROP TABLE “‘ || tablename || ‘” cascade;’ from pg_tables;

To check if a table exist and then to drop it if it does

select ‘DROP TABLE IF EXISTS “‘ || tablename || ‘” cascade;’ from pg_tables;