Gain a deeper understanding of SchemaQuench.
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.
Quenching a template happens as a series of ordered events. Each slot must complete successfully
before we move to the next except as noted below.
Before Migration scripts which are located in MigrationScripts\Before under each template.Object scripts which are located in the following folders under each template.
Object scripts that failed to apply before the table changes plus any AfterTablesObject scripts. We loop again to resolve dependencies and finally report errors if any scripts failed to apply.
TableData Folder under each template.After Migration scripts which are located in MigrationScripts\After under each template.Object scripts are always applied and Quench will loop through them to resolve dependencies if possible. We lean heavily on deferred name resolution and only fail if we cannot resolve a dependency multiple times after tables have been updated.
Quenching tables is achieved via a stored procedure SchemaSmith.TableQuench that we
add to each database during the quenching process. This procedure is provided with the JSON
definition for all tables in the product as a template and performs a step-by-step automated
process to reshape them if needed. We cannot automate 100% of every possible change, but we do
the bulk of the heavy lifting here and provide the migration scripts
concept for edge cases and things you need to perform beyond this automation.
The following are the steps for quenching tables:
ProductNameProductName property so that we can drop the indexes that have been removed from the product even if the product is configured with DropUnknownIndexes set to false.DropUnknownIndexes is set to true at the product level OR when the unknown index is impacted by a column changeUpdateFillFactor is set to true in the template definition.