SchemaTongs PostgreSQL Enterprise Documentation

Extract PostgreSQL Metadata with Confidence

SchemaTongs casts your database into versionable metadata-tables, views, procedures, and more-ready for deployment across environments.

SchemaTongs

Overview

SchemaTongs is the starting point of the SchemaSmith workflow. It connects to a PostgreSQL database and extracts metadata representing the current state of that database - tables, procedures, views, etc. This metadata becomes the raw material that feeds into the SchemaSmith toolchain for shaping and deploying your desired state across environments. We call this initial process of extracting schema definitions casting the database.

Simply point the application at each of your databases and everything within them will be extracted out to the folder of your choosing.

Where SchemaTongs Fits

  • SchemaTongs extracts your schema into metadata.
  • SchemaHammer provides powerful search and edit capabilities for your metadata.
  • SchemaQuench applies your schema and data metadata to your Postgres server.
  • DataTongs extracts your seed data into metadata

Quick Start Guide

1. Configure your appSettings.json
Setting Value
Source:ServerThe server to connect and extract from.
Source:UserThe user to authenticate with. Leave blank to use Windows authentication.
Source:PasswordThe password to authenticate with. Leave blank to use Windows authentication.
Source:DatabaseThe database to extract from.
Product:PathThe base path for the product to write the metadata files to.
Product:NameThe product name to write in product.json if one doesn't yet exist. Defaults to the final directory name in Path if omitted.
Template:NameThe template name to write in template.json if one doesn't yet exist. Defaults to Source:Database if omitted.
ShouldCast:TablesIndicates whether Tables should be included in the current export. Defaults to true.
ShouldCast:SchemasIndicates whether Schemas should be included in the current export. Defaults to true.
ShouldCast:DomainTypesIndicates whether Domain Types should be included in the current export. Defaults to true.
ShouldCast:EnumTypesIndicates whether Enum Types should be included in the current export. Defaults to true.
ShouldCast:CompositeTypes Indicates whether Composite Types should be included in the current export. Defaults to true.
ShouldCast:Functions Indicates whether Functions, Trigger Functions and Window Functions should be included in the current export. Defaults to true.
ShouldCast:AggregatesIndicates whether Aggregates should be included in the current export. Defaults to true.
ShouldCast:ProceduresIndicates whether Procedures should be included in the current export. Defaults to true.
ShouldCast:SequencesIndicates whether Sequences should be included in the current export. Defaults to true.
ShouldCast:RulesIndicates whether Rules should be included in the current export. Defaults to true.
ShouldCast:TriggersIndicates whether Triggers should be included in the current export. Defaults to true.
ShouldCast:ViewsIndicates whether Views should be included in the current export. Defaults to true.
ShouldCast:ObjectListA comma or semicolon delimited list of object names you wish to include in the current export. Leave blank for all.
2. Run SchemaTongs

Execute SchemaTongs from the command line and the casting process will begin.

> SchemaTongs
3. Shape your metadata

Move on to editing your metadata with SchemaHammer.

See the SchemaTongs Walkthrough to help you get started with the tool.

Tip

The same concepts for how to override appSettings.json for SchemaQuench apply to SchemaTongs. You can also use Command Line Options to specify the log file location or an alternate config file.

What is Exported

Objects Directory
product.jsonProduct:Path
template.jsonProduct:Path\Templates\Template:Name
SchemasProduct:Path\Templates\Template:Name\Schemas
Domain TypesProduct:Path\Templates\Template:Name\Domain Types
Enum TypesProduct:Path\Templates\Template:Name\Enum Types
Composite TypesProduct:Path\Templates\Template:Name\Composite Types
FunctionsProduct:Path\Templates\Template:Name\Functions
Trigger FunctionsProduct:Path\Templates\Template:Name\Trigger Functions
Window FunctionsProduct:Path\Templates\Template:Name\Window Functions
AggregatesProduct:Path\Templates\Template:Name\Aggregates
ProceduresProduct:Path\Templates\Template:Name\Procedures
SequencesProduct:Path\Templates\Template:Name\Sequences
TablesProduct:Path\Templates\Template:Name\Tables
RulesProduct:Path\Templates\Template:Name\Rules
TriggersProduct:Path\Templates\Template:Name\Triggers
ViewsProduct:Path\Templates\Template:Name\Views

Export Notes:

  • product.json: Will be created for the first cast to a given product path. New templates will be added to the TemplateOrder. You should tweak any properties such as the ValidationScript to suit your actual needs.
  • template.json: Will be created for the first cast to a given template path. You should tweak any properties such as the DatabaseIdentificationScript and VersionStampScript to suit your actual needs.

Best Practices

  • Incremental Adoption: Begin with non-critical objects to familiarize yourself with the tool's workflow.
  • Version Control Integration: Keep your metadata files under source control to track changes and collaborate effectively.
  • Environment Segregation: Use different configurations for development, staging, and production to prevent accidental deployments.
  • Regular Validation: Periodically validate that the target databases match the desired state defined in your metadata.

Tip

Pair SchemaTongs with automated checks running SchemaQuench in CI so every cast is tested and versioned before it reaches production.

Additional Resources