SchemaSmith Documentation

SchemaQuench Walkthrough

How to quench your first database with SchemaQuench

SchemaQuench

Overview

This guide continues the walkthrough started with SchemaTongs and assumes you already have the extracted repository.

Prerequisites & Setup

To begin, ensure access to a running Microsoft SQL Server with the test product databases already created. If you do not have it, you can use this creation script.

Install SchemaQuench and configure the AppSettings.json file with the server, login details, and the SchemaPackagePath pointed to the directory that contains your Product.json file. The file should look something like:


{
    "Target": {
        "Server": "localhost,1440",
        "User": "TestUser",
        "Password": "****************"
    },
    "WhatIfONLY": false,
    "SchemaPackagePath": "C:/Temp/Tutorial/TestProduct"
}
                    

Make some changes

Navigate to C:\Temp\Tutorial\TestProduct\Templates\TestMain\Tables and edit dbo.TestTable.json adding a column like:


{
...
  "Columns": [
    {
      "Name": "[MyNewColumn]",
      "DataType": "INT",
      "Nullable": false,
      "Default": "42"
    },
    {
      "Name": "[DateCreated]",
      "DataType": "DATETIME",
      "Nullable": true,
      "Persisted": false,
      "Sparse": false,
      "Collation": "",
      "DataMaskFunction": ""
    },
...
}
                    

We will also create a new stored procedure. Navigate to C:\Temp\Tutorial\TestProduct\Templates\TestSecondary\Procedures and create the file dbo.MyProcedure.sql containing the following text:


CREATE OR ALTER PROCEDURE dbo.MyProcedure
AS
BEGIN
    SELECT 42
END
                    

Run SchemaQuench and verify your changes

This is a console application, so it is recommended that you run from a command prompt. The need to create directories may require the command prompt to be opened in Administrator mode.

The tool will output progress to the console window. You should see something like the following to see that the changes occurred.


...
2025-06-09 14:38:46,765 - [TestMain]       Add New Physical Columns
2025-06-09 14:38:46,765 - [TestMain]         Adding new columns to [dbo].[TestTable] ([MyNewColumn])
2025-06-09 14:38:46,769 - [TestMain]       Detect Default Changes
...
2025-06-09 14:38:47,625 - [TestSecondary]   Quenching object scripts
2025-06-09 14:38:47,625 - [TestSecondary]     Quenching /Users/robertrehberg/src/TestProduct/Templates/TestSecondary/Procedures/dbo.MyProcedure.sql
2025-06-09 14:38:47,626 - [TestSecondary]   Quenching tables
...
2025-06-09 14:38:47,714 - [TestSecondary] Successfully Quenched
2025-06-09 14:38:47,714 - Completed quench of TestProduct
                    

If you run SchemaQuench again without any changes, you should not see the Adding new columns message, however, you will continue to see the quenching of the stored procedure as sql scripts are always applied.

Important

All sql scripts must be idempotent or later runs will fail.

Additional Resources