pg_dump does not write "CREATE EXTENSION postgis;"
You can use this to dump schema and extensions (tested on 11.2):
pg_dump -U postgres -d mydb -s > dump.sql
Several possibilities:
This database has been upgraded from an old version where
CREATE EXTENSION
did not yet exist.Somebody mistakenly installed PostGIS by executing the SQL script rather than running
CREATE EXTENSION
.You don't dump the whole database, but restrict the dump to a schema using the
-n
option.