apgdiff Documentation

repository·develop·Indexed 18 days ago

https://github.com/fordfrog/apgdiff

A 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.

Tokens
425
Snippets
1
Records
4
Agent score
14%

What's inside apgdiff

  1. Overview of apgdiff

    develop
    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.
  2. Best practices for CREATE TABLE constraints

    develop

    To 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.

  3. Use CLI switches to modify diffing behavior

    develop

    apgdiff provides several command-line switches to customize how it parses and outputs schema differences:

    • --ignore-slony-triggers: Causes Slony triggers (_slony_logtrigger and _slony_denyaccess) to be completely ignored during parsing and diffing.
    • --ignore-schema-creation: Removes the need for CREATE SCHEMA declarations 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).