use if not exists to check if table exists postgresql code example
Example: how to check table exists or not in postgresql
SELECT 1 FROM information_schema.tables
WHERE table_schema = 'schema_name' AND table_name = 'table_name';
SELECT 1 FROM information_schema.tables
WHERE table_schema = 'schema_name' AND table_name = 'table_name';