SchemaQuench turns fragile, step-by-step scripts into safe, declarative releases-so every deployment is boring, predictable, and fast.
SchemaQuench is a state-based, opinionated database migration tool inspired by the principles of infrastructure-as-code tools like HashiCorp's Terraform. It enables you to define the desired end state of your SQL Server databases using metadata and applies these definitions to target servers, ensuring consistency and repeatability across environments. We refer to this process as quenching.
Traditional migration scripts track changes over time but can become cumbersome and error-prone, especially in complex environments. SchemaQuench offers a declarative approach, focusing on the desired final state rather than the sequence of changes. This methodology:
TemplateOrder contains all your templates in the order they need to be
quenched.
template.json to find the
correct database(s) to apply against, along with version validation and stamping scripts.
You can use Command Line Options to specify the log file location or an alternate config file.
See the SchemaQuench Walkthrough to help you get started with the tool.
Start by defining a small subset of your database objects. Gradually expand as you gain confidence, ensuring that each step is manageable and verifiable.
Say you are widening a column from VARCHAR(5) to VARCHAR(10).
On the surface, that is a simple alter table script, however, what if that column
participates in:
In that case, you have to drop those constructs, make your change and then put them back on. That is a lot of bookkeeping for a simple change. Why bother? SchemaQuench can handle all of that for you. You widen the column in the table's json, SchemaQuench handles the dependencies. For more details about the quenching process see Forge Deeper with SchemaQuench.
We now support renaming tables and columns. See defining tables for more details.
When SchemaQuench detects that a table should be dropped, ie it was once defined in the product but has been removed, it looks to see if there is a stored procedure named [SchemaSmith].[CustomTableDrop]. If there is such a procedure, it calls it passing the schema and name of the table as the first and second parameters respectively and skips actually dropping the table.
Similarly, near the beginning of the quench process, an attempt is made to restore tables that had been custom dropped previously. This hook expects a stored procedure named [SchemaSmith].[CustomTableRestore] passing the same schema and name parameters.
These hooks allow you to time delay dropping tables or to perform some custom backup procedure or whatever else your process may require.