Search code examples
postgresqlhomebrewpg-dump

Why does pg_dump add extra comments for public schema?


When I run pg_dump -d <database_name> --schema-only --no-privileges --no-owner --no-comment --file db/structure.sql it adds these lines to the dump:


--
-- Name: public; Type: SCHEMA; Schema: -; Owner: -
--

-- *not* creating schema, since initdb creates it

This is different for installations on different machines (not using Homebrew) with the same version. There it does not add these lines.

I installed Postgres via Homebrew.

Is there a way to configure this? Why are these lines added?

Tried different versions of postgres (15.5, 16.2). Tried on a different machine where it was not installed using Homebrew.

I could not find anything in the documentation for pg_dump: https://www.postgresql.org/docs/15/app-pgdump.html I also could not find anything in the server settings: https://www.postgresql.org/docs/15/runtime-config.html

I expect the same versions on different machines to give the same output if the settings are the same.


Solution

  • When I delete the whole data directory and recreated it by reinstalling I did not get the extra comments. The old data directory was a upgrade from a Postgres 14 data directory. Why this caused the extra comments is still unclear to me.