# README
PostgreSQL Schema Dump Sanitiser
This go library serves to produce a more human readable schema dump by cleaning up the output from PostgreSQL's pg_dump -s
command.
The library was last updated with PostgreSQL 11.
Setup
go get -u github.com/jchiam/psql-schema-dump-sanitiser
Linting
go get -u github.com/golang/lint/golint
golint <path>
Tests
go test <path>
Usage
Run from your $GOPATH
:
psql-schema-dump-sanitiser <input path> > <output path>
Outstanding Issues
Specifications
The processing mechanism is as follows.
- Redunant lines such as comments,
SET
,EXTENSIONS
andOWNER
statements are removed CREATE TABLE
statements are parsed into table maps containing column information- Any multi-line statements are squashed into single line statements
- Sequences are parsed and process through the following
- Modifiers with default values are removed for
CREATE SEQUENCE
statements CREATE SEQUENCE
andALTER SEQUENCE
statements are mapped respectively to their tables
- Modifiers with default values are removed for
- Default values are added to the table columns
- Constraint statements are mapped to tables and columns are marked as primary key or foreign key
- Indices statements are mapped to tables
- If there are anymore unprocessed lines, fatal error occurs
- Print output (tables are printed in topological order to ensure referential integrity when dumping into database)