Configure your project folder layout to suit your team's needs.
A sample product script folder setting may be something like this added to your product.json:
{
"ScriptFolders": [
{ "FolderPath" : "Before Product", "QuenchSlot" : "Before" },
{ "FolderPath" : "Jobs", "QuenchSlot" : "After", "ServerToQuench" : "Both" },
{ "FolderPath" : "After Product", "QuenchSlot" : "After" }
]
}
FolderPath: Relative path from the product.json file where the scripts reside.QuenchSlot: Either Before or After, allowing scripts to run prior to or following the template quenches.ServerToQuench: Specifies where the scripts should run: Primary, Secondary or Both. Defaults to Primary.
ServerToQuench controls behavior in clustered environments; for example,
login creation typically needs to run on both the primary and secondary servers,
whereas function creation can only run on the primary, which is synchronized automatically
by an Availability Group. The primary and secondary servers
configurations reside in appSettings.json.
In the code snippet above, the Before Product and After Product
are defaulting the ServerToQuench to Primary taking unnecessary
clutter out of the JSON. Jobs are defined as both so that they are applied to secondary
servers and present in the event of a failover. The code within each job would need to
detect if they are running on the primary or secondary and behave appropriately.
A sample template script folder setup may be something like this added to your template.json:
{
"ScriptFolders": [
{ "FolderPath" : "MigrationScripts/Before", "QuenchSlot" : "Before" },
{ "FolderPath" : "Schemas", "QuenchSlot" : "Objects" },
{ "FolderPath" : "DataTypes", "QuenchSlot" : "Objects" },
{ "FolderPath" : "FullTextCatalogs", "QuenchSlot" : "Objects" },
{ "FolderPath" : "FullTextStopLists", "QuenchSlot" : "Objects" },
{ "FolderPath" : "Functions", "QuenchSlot" : "Objects" },
{ "FolderPath" : "Views", "QuenchSlot" : "Objects" },
{ "FolderPath" : "Procedures", "QuenchSlot" : "Objects" },
{ "FolderPath" : "Triggers", "QuenchSlot" : "AfterTablesObjects" },
{ "FolderPath" : "MigrationScripts/After", "QuenchSlot" : "After" }
]
}
FolderPath: Relative path from the template.json file to the relevant script folder.QuenchSlot: Specifies script execution timing and behavior. Valid values include:
The None Quench Slot is included simply to have the folder present in
SchemaHammer, but it will not be executed by SchemaQuench unless they are specified in a
QueryToken.
The order the folders are declared is the order they will be processed within their
respective slots. In other words, if in the example above you moved Schemas
above MigrationScripts/Before, the order processed would still be
MigrationScripts/Before, Schemas, DataTypes and so on.