SchemaTongs Enterprise Documentation

Extract SQL Server 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 SQL Server 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 SQL Servers.
  • 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:TablesInclude Tables in the export. Defaults to true.
ShouldCast:SchemasInclude Schemas in the export. Defaults to true.
ShouldCast:UserDefinedTypesInclude User Defined Types in the export. Defaults to true.
ShouldCast:UserDefinedFunctionsInclude User Defined Functions in the export. Defaults to true.
ShouldCast:ViewsInclude Views in the export. Defaults to true.
ShouldCast:StoredProceduresInclude Stored Procedures in the export. Defaults to true.
ShouldCast:TableTriggersInclude Table Triggers in the export. Defaults to true.
ShouldCast:CatalogsInclude Full Text Catalogs in the export. Defaults to true.
ShouldCast:StopListsInclude Full Text Stop Lists in the export. Defaults to true.
ShouldCast:DDLTriggersInclude Database DDL Triggers in the export. Defaults to true.
ShouldCast:XMLSchemaCollectionsInclude XML Schema Collections in the export. Defaults to true.
ShouldCast:ScriptDynamicDependencyRemovalForFunctionsIndicates whether each scripted function should include code to dynamically remove any computed column, constraint, and indexes dependent on the function before updating it. The table update will restore them for any tables managed in the product. Depending on your environment and the impact of this, you might choose to handle such dependencies in another way. This option defaults to false.
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
User Defined TypesProduct:Path\Templates\Template:Name\DataTypes
DDL TriggersProduct:Path\Templates\Template:Name\DDLTriggers
Full Text CatalogsProduct:Path\Templates\Template:Name\FullTextCatalogs
Full Text Stop ListsProduct:Path\Templates\Template:Name\FullTextStopLists
FunctionsProduct:Path\Templates\Template:Name\Functions
ProceduresProduct:Path\Templates\Template:Name\Procedures
SchemasProduct:Path\Templates\Template:Name\Schemas
TablesProduct:Path\Templates\Template:Name\Tables
TriggersProduct:Path\Templates\Template:Name\Triggers
ViewsProduct:Path\Templates\Template:Name\Views
XML Schema CollectionsProduct:Path\Templates\Template:Name\XMLSchemaCollections

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