SchemaSmith PostgreSQL Enterprise 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 PostgreSQL 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",
        "User": "TestUser",
        "Password": "******************************",
        "SecondaryServers": ""
    },
    "MaxThreads": 10,
    "WhatIfONLY": false,
    "SchemaPackagePath": "c:/temp/postgres/TestProduct"
}

Make some changes

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

{
...
  "Columns": [
    {
      "Name": "MyNewColumn",
      "DataType": "INT",
      "Nullable": false,
      "Default": "42",
      "Generated": "NEVER",
      "Storage": "PLAIN",
      "Compression": "DEFAULT",
      "OldName": ""
    },
    {
      "Name": "DateCreated",
      "DataType": "timestamp",
      "Nullable": true,
      "Generated": "NEVER",
      "Storage": "PLAIN",
      "Compression": "DEFAULT",
      "OldName": ""
    },
,,,
}

We will also create a new stored procedure. Navigate to C:\Temp\postgres\TestProduct\Templates\TestSecondary\Functions and create the file public.MyFunction..sql containing the following text:

CREATE OR REPLACE FUNCTION public."MyFunction"()
  RETURNS INT
  LANGUAGE plpgsql
AS $function$
BEGIN
    RETURN (SELECT 42);
END $function$;

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-11-09 15:29:36,069 - [localhost].[TestMain]       Add New Physical Columns
2025-11-09 15:29:36,087 - [localhost].[TestMain]         Add new physical columns to public.TestTable (MyNewColumn)
2025-11-09 15:29:36,090 - [localhost].[TestMain]   Quenching object scripts without query tokens
...
2025-11-09 15:29:36,956 - [localhost].[TestSecondary]   Quenching object scripts without unresolved tokens
2025-11-09 15:29:36,963 - [localhost].[TestSecondary]     Quenched c:\temp\postgres\TestProduct\Templates\TestSecondary\Functions\public.MyFunction.sql
2025-11-09 15:29:36,963 - [localhost].[TestSecondary]   Quenching missing tables and columns
...
2025-11-09 15:29:37,141 - [localhost].[TestSecondary] Successfully Quenched
2025-11-09 15:29:37,317 - Quenching After Product Scripts to localhost
2025-11-09 15:29:37,425 - 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 function as sql scripts are always applied.

Important

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

Additional Resources