apgdiff Documentation
repository·develop·Indexed 18 days ago
https://github.com/fordfrog/apgdiffA specialized tool for comparing PostgreSQL database schemas. apgdiff parses SQL dump files and generates the SQL statements required to synchronize differences between two schemas, supporting various CLI switches to modify diffing behavior and character set customization.
What's inside apgdiff
- apgdiff is a free PostgreSQL diff tool used for comparing and diffing database schemas. It is designed to analyze schema dumps and generate the necessary SQL statements to transform one schema into another.
Best practices for CREATE TABLE constraints
developTo ensure reliable parsing, it is recommended to use explicit constraint naming when creating tables. Instead of using unnamed constraints, use the following syntax:
CREATE TABLE ... CONSTRAINT name PRIMARY KEY/UNIQUE ...apgdiff may have difficulty supporting unnamed constraints.
Use CLI switches to modify diffing behavior
developapgdiff provides several command-line switches to customize how it parses and outputs schema differences:
--ignore-slony-triggers: Causes Slony triggers (_slony_logtriggerand_slony_denyaccess) to be completely ignored during parsing and diffing.--ignore-schema-creation: Removes the need forCREATE SCHEMAdeclarations in the input files.--output-ignored-statements: Outputs statements that apgdiff ignores in the dump files. This is useful for identifying unsupported commands that may need manual handling.--list-charsets: Outputs a list of all supported character sets.--add-defaults: When specified, ensures default values are handled (note: historical versions had issues with dropping defaults when this was used; ensure you are using a recent version).
Use apgdiff via the CLI
developapgdiff is a tool that compares two PostgreSQL dumps and outputs the differences in the database schemas. It is executed via the
Mainclass entrypoint, which parses command-line arguments and generates a diff output. The tool supports custom output character sets.java -cp <classpath> cz.startnet.utils.pgdiff.Main <args>