I am looking for a way to dump PostgreSQL12 database model into a directory/file structure, instead of a single file - for versioning purposes.

I found this old thread, which mentions this exact case and describes a --split flag to be used with pg_dump.

However, this option does not exist in the current pg_dump for PostgreSQL12. I also tried the option --format=directory but that's not it. How do I achieve this effect?

1 Answer 1


The directory format will write one file per table, so that sounds like a good candidate. But if you are interested in a text diff, it is of course useless.

The only thing I can think of is to dump each table, view and function separately using the -t option. You might still be disappointed if you want a diff of the table contents, because rows in a PostgreSQL table keep changing position.

Best practice is not to meddle with the database and then to reverse engineer a diff, but to use a schema versioning tool like Liquibase and write SQL diff files yourself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.