SchemaTongs Walkthrough — PostgreSQL
Point SchemaTongs at a PostgreSQL database, extract the live schema into structured JSON and SQL files, and explore the package ready for version control — the cast leg of the SchemaSmith cycle in 10 minutes.
SchemaTongs grips your live schema and casts it into structured files.
Prerequisites
You need three things before starting the walkthrough — the SchemaSmith binaries, a PostgreSQL server you can read from, and the demo schema package this walkthrough drives.
SchemaSmith tools
Download self-contained ZIP packages from the latest GitHub release and extract them anywhere on your PATH. No .NET runtime required.
A database server
Either an existing PostgreSQL instance or Docker (recommended). The SchemaSmith repository includes a Docker Compose file that starts the demo server for you.
The demo files
Clone the repository or download just the Demos/ folder:
git clone https://github.com/Schema-Smith/SchemaSmithyFree.git
cd SchemaSmithyFree
Step 1: Start the Demo Environment
Each platform has its own demo folder under Demos/ with a run-demo launcher, a docker-compose.yml, and a .env credentials file. From the repository root, launch the PostgreSQL demo:
cd Demos\PostgreSQL
run-demo.cmd
cd Demos/PostgreSQL
./run-demo.sh
The launcher runs build-schemaquench.sh to compile the SchemaQuench binary (requires the .NET SDK on the host), then docker compose up --build packages that binary into a local Docker image, starts a PostgreSQL instance on port 5432, and deploys the demo databases using SchemaQuench. The launcher blocks until the completed service exits, which signals the databases are ready. Credentials live in Demos/PostgreSQL/.env:
| Setting | Value |
|---|---|
| PostgreSQL | localhost:5432 |
| User | testuser |
| Password | (see Demos/PostgreSQL/.env) |
Step 2: Cast with SchemaTongs
Now let's go the other direction. Pretend you already have a database and want to bring it under SchemaSmith management. SchemaTongs grips your live schema and casts it into structured files.
Create a SchemaTongs configuration file called tongs-extract.json:
{
"Source": {
"Platform": "PostgreSQL",
"Server": "localhost",
"Port": "5432",
"User": "testuser",
"Password": "your-password-here",
"Database": "northwind"
},
"Product": {
"Path": "./my-northwind",
"Name": "Northwind"
},
"Template": {
"Name": "Northwind"
},
"ShouldCast": {
"Tables": true,
"Schemas": true,
"Functions": true,
"Views": true,
"Procedures": true,
"TableTriggers": true,
"DomainTypes": true,
"EnumTypes": true,
"CompositeTypes": true,
"Aggregates": true,
"Sequences": true,
"Rules": true,
"MaterializedViews": true
}
}
Run the extraction:
SchemaTongs --ConfigFile:tongs-extract.json
Look at what appeared in the my-northwind/ folder. You now have a complete schema package:
my-northwind/
Product.json ← Platform, templates, tokens
.json-schemas/ ← JSON Schema validation, generated on the fly
Templates/
Northwind/
Template.json
Tables/
public.categories.json
public.customers.json
public.orders.json
... (13 tables)
Views/
public.alphabetical_list_of_products.sql
...
Procedures/
public.cust_order_hist.sql
...
Schemas/
Functions/
Triggers/
Table Data/
Every table is a JSON file describing its columns, indexes, and constraints. Every function and view is a plain SQL file. This is your entire database — materialized as readable, diffable, reviewable source files. Commit this to source control and you have a complete history of every schema change from this point forward. For the full set of extraction options, see the SchemaTongs reference.
That's the cast. A live database, captured in files you can read, review, and version.
Step 3: Explore the Package
No GUI editor needed — the schema package is designed to read clearly in any editor or IDE. Open my-northwind/ in VS Code, JetBrains Rider, Visual Studio, or whatever your team uses. The .json-schemas/ folder gives you validation and autocomplete for every JSON file in the package automatically.
Click through Tables/public.categories.json. You'll see the column definitions, the primary key, and any indexes. Open a function in Functions/ and you see the full SQL definition ready to diff in a pull request. This is what schema review looks like when the files are designed for it: structured enough for tools, readable enough for humans, diff-friendly enough for code review.
Take a minute to click around. Every table, every view, every function in the Northwind database is here, structured and browsable. No server connection needed to explore.