TLDR; Key/Value pairs that allow deferred resolution.
A script token is a key/value pair that you reference using {{..}}
delimiters. At runtime, the placeholder is replaced with the corresponding value.
This allows you to abstract and defer values until execution time. Script tokens are
defined in the ScriptTokens section of either product.json
or template.json, and can be used within any SQL script or script property.
| Token Name | Value |
|---|---|
| ProductName | Automatically set to your product's name. |
| TemplateName | Set to the name of the current template being quenched (available only within the template scope). |
| TableSchema | A JSON array of all the table JSON objects at the current template level. |
| SpecificTable | Lets you reference the JSON of a specific table within the template. |
| TableSchema_<TemplateName> | For each template in the product, this provides access to a metadata structure (useful for shared data dictionaries). |
ReleaseVersion in your product.json
{
"ScriptTokens": {
"ReleaseVersion": "1.0.0"
}
}
Can be used in a template:
{
"VersionStampScript": "INSERT ProductVersions(Product, Version) VALUES( '{{ProductName}}', '{{ReleaseVersion}}')"
}
Product level script tokens can be overridden via appSettings or environment variables.
product.json and/or template.json.product.json and template.json.If the same token exists at both product and template levels, the token closest to the script context takes precedence. For example, if used in a stored procedure script it resolves from the template; in product validation scripts, it resolves from the product-level definition.
These tokens allow you to reference the JSON for a specific table in a script-ideal for migration scenarios where you want to avoid duplication.
They are defined like this:
{
"ScriptTokens": {
"dbo.MyTable Schema": "<*SpecificTable*>dbo.MyTable"
}
}
Query tokens execute an SQL query and store the first column of each result row as lines in a string.
Define one like this:
{
"ScriptTokens": {
"DatabaseList": "<*Query*>SELECT [Name] FROM master.dbo.sysdatabases WHERE [Name] IN ('master', 'tempdb') ORDER BY [Name]"
}
}
The DatabaseList value becomes:
master
tempdb
Formatting must be handled by your SQL. No assumptions are made by the system.
These tokens load file content into the token's value.
<*File*>: Load textual content, such as JSON for data insertion.<*BinaryFile*>: Load binary content, such as a CLR DLL for deployment.Examples:
{
"ScriptTokens": {
"MyTableData": "<*File*>Tables/dbo.MyTable.data",
"CLRAssembly": "<*BinaryFile*>Files/MyCLR.dll"
}
}
Use Cases:
This hybrid token loads the content of a file, executes it as a query, and uses the results like a query token.
Defined like:
{
"ScriptTokens": {
"MyGeneratedCode": "<*QueryFile*>Query Files/Generate select list for latest column definition.sql"
}
}
Scripts within Query and QueryFile tokens may themselves include non-query script tokens, which will be resolved prior to execution.
Table-level
custom properties can be referenced within
scripts for that table or its components. Use the {{...}} syntax,
and prefix property names with Table. to accurately reference the table-level
context. You can also reference any properties for the current table component using the same
syntax but without the prefix.