Add the --clean command when taking a dump of the postgres database.
When you run pg_dump with --clean, the dump file will include DROP statements before each object (TABLE, SEQUENCE, VIEW, etc.).
If you restore a dump with --clean, you don’t need to manually drop tables first.
Restores become idempotent — safe to run even if the DB already has some objects.
Add the
--cleancommand when taking a dump of the postgres database.When you run pg_dump with --clean, the dump file will include DROP statements before each object (TABLE, SEQUENCE, VIEW, etc.).
If you restore a dump with --clean, you don’t need to manually drop tables first.
Restores become idempotent — safe to run even if the DB already has some objects.