Force qualified names in dump
Is it possible to force dump to qualify all table references? This would make the output easier to integrate in workflows that expect a specific schema to be used. It would also make the output more consistent as e.g. functions that reference tables in a qualified way still do so in the dump.
We try to be intelligent about dumping a schema-agnostic dump so that it can be used to diff between different pg schemas.
Do you have a particular example to show what you'd like?
We have a database where we use qualified names in functions so those end up in the dump as well, however the table definitions are not qualified. It wouldn't be meaningful to retarget these to a different schema. In addition, we also use qualified names in migrations and queries. This makes directly integrating pgschema into our workflow tricky since we need to postprocess any dump to make it directly usable. I realize pgschema can qualify names in migrations, however we'd like to also use the dump for other purposes (setting up test instances, sqlc-style codegen, etc). It seems that qualifying the dumps from pgschema is the simplest solution, though I'm open to ideas.
Would prepend SET search_path when using the dump work?
SET search_path TO public; \i pgschema_dump.sql
This makes all unqualified names resolve to your target schema.
This makes all unqualified names resolve to your target schema.
Wouldn't that make them resolve to public?
To be clear the issue is with what I'm feeding the schema to (in this case sqlc),as setting the search path doesn't help. Loading the dump into a real postgres instance isn't an issue as that will respect search_path, but sqlc seems to get confused. For the moment I'm working around the issue downstream of pgschema since it's not an issue with the dump, although being able to force a qualifier would make it easier to integrate in this setup.
Tried to strip qualifier from function body. Let's see how that goes.