mirror of
https://github.com/HannahVernon/pg-extract-schema.git
synced 2026-05-27 13:54:19 -05:00
Command-line tool for extracting object definitions from a PostgreSQL database.
- C# 100%
|
|
||
|---|---|---|
| .github | ||
| .gitignore | ||
| CODE_OF_CONDUCT.md | ||
| CONTRIBUTING.md | ||
| Directory.Build.props | ||
| global.json | ||
| LICENSE | ||
| pg-extract-schema.csproj | ||
| pg-extract-schema.sln | ||
| Program.cs | ||
| README.md | ||
| SchemaExtractor.cs | ||
| SECURITY.md | ||
pg-extract-schema by Hannah Vernon
Overview
This project is designed to extract schema information from PostgreSQL databases in an efficient and comprehensive manner.
Features
- 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
Requirements
- PostgreSQL 9.6 or later.
- DotNet 9.0 Runtime or later.
Installation
- 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
Usage
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 information
Examples
pg-extract-schema.exe -h mypgserver -p 5432 -d mydatabase -U me -o c:\temp\pg_schema
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
- 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.
Support
For support, please open an issue in the GitHub repository. We will try to respond as quickly as possible.
Changelog
[1.0.0] - 2026-03-19
- Initial release