This project is designed to extract schema information from PostgreSQL databases in an efficient and comprehensive manner.
- Extracts DDL for the following object types, each into discrete
.sqlfiles:- Extensions
- Schemas
- Sequences (with full attributes)
- Types (enums, composites, and domains)
- Tables (with columns, defaults, primary keys, unique constraints, check constraints, and comments)
- Indexes (non-PK, non-unique-constraint)
- Foreign keys
- Views
- Materialized views
- Functions and procedures
- Triggers
- PostgreSQL 9.6 or later.
- DotNet 9.0 Runtime or later.
- Clone the repository:
git clone https://github.com/HannahVernon/pg-extract-schema.git cd pg-extract-schema - Install dependencies
winget install Microsoft.DotNet.SDK.9
- Build the binaries.
dotnet build
Run the executable with appropriate parameters:
Description:
Extract DDL from a PostgreSQL database into discrete .sql files
Usage:
pg-extract-schema [options]
Options:
-h, --host <host> (REQUIRED) PostgreSQL server hostname
-p, --port <port> PostgreSQL server port [default: 5432]
-d, --database <database> (REQUIRED) Database name
-s, --schema <schema> Schema name (default: all non-system schemas)
-o, --output <output> Output directory [default: output]
-U, --username <username> PostgreSQL username [default: postgres]
-W, --password <password> PostgreSQL password (or set PGPASSWORD env var). If password is not supplied on the command-line or via the environment variable, pg-extract-schema will ask for the password.
--include-postgres-system-objects Include PostgreSQL system schemas (pg_catalog, pg_toast, information_schema, pg_temp) and the plpgsql extension [default: False]
--include-pg-toast Include pg_toast schema objects (excluded by default) [default: False]
--version Show version information
-?, -h, --help Show help and usage informationpg-extract-schema.exe -h mypgserver -p 5432 -d mydatabase -U me -o c:\temp\pg_schemaThis project is licensed under the MIT License - see the LICENSE file for details.
- Fork the repository.
- Create a new branch (
git checkout -b feature-foo). - Make your changes and commit them (
git commit -m 'Add some feature'). - Push to the branch (
git push origin feature-foo). - Open a pull request.
For support, please open an issue in the GitHub repository. We will try to respond as quickly as possible.
- Initial release