The Tier 3 tools create and change the files in your schema package: tables, views, scripts, templates and settings. Each one checks what it is about to write before anything changes on disk.
By the SchemaSmith Team · Last reviewed
Tools that create or change files in your schema package.
The Tier 3 tools change files on disk: table, view and object definitions, SQL scripts, Product.json and Template.json. None of them connects to a database. Every change to a package file follows the same rules:
SchemaQuench --Validate would use. A warning from those checks is written, and the result says so. Only what the call introduces counts, so a file that already breaks a rule still takes an unrelated change, and the call that repairs it is never blocked.A schema package is checked out on Windows, Linux and macOS, so a name a tool turns into a file or folder has to be valid on all three. On every operating system, these tools refuse a new name that:
< > : " / \ | ? * or a control character;CON, NUL, COM1 or LPT1, with or without an extension;The rule applies to schemasmith_create_product (when no path is given, so the name becomes the folder), schemasmith_create_template, schemasmith_add_folder, schemasmith_save_script and schemasmith_create_package. Nothing is written when a name is refused, and the message says which rule it breaks. It applies to new names only. Names inside the JSON, such as a table's Name, are not restricted, because tables, views and the other typed objects are stored under an encoded file name.
A Modify tool is confirmed before it writes, and how depends on where you call it:
confirm: true. Without it, nothing runs, and the reply says the call needs confirmation. For a tool reached through schemasmith_execute_tool, confirm: true goes beside tool_name, not inside the inner arguments. MCP Server Setup covers it in full.ask-forge CLI. The command shows what it is about to write and asks you to confirm. --yes, or -y, answers yes for that one command. With no terminal to answer the prompt, the command stops with an error and writes nothing, so a script passes --yes. The agent.confirmationLevel setting decides which commands ask for confirmation. With always, the default, it asks before Modify and External commands. With external, it asks before External commands only. With never, it does not ask. Configuration describes the setting.operator trust level, and it asks you before each one while confirmTier3 is on, as it is by default. Trust Levels explains each level.Create tables, change them, and rename them along with everything that names them. On the CLI, each tool is a kebab-case subcommand and each parameter a kebab-case option, and --help on any command lists every option.
The general-purpose table editor. Each call makes one change to one table's JSON file. It can add, modify or remove a column, an index, a foreign key or a check constraint, and it can set the table's description or its Online Apply setting. On SQL Server and PostgreSQL it can also add, modify or remove a statistic. On SQL Server it can also set or remove a table's full-text index. A SQL Server table also takes spatial and JSON indexes, edge constraints, a ledger view and change data capture. Property names are the schema model's own, the same names your table files already use. Letter case and a few common synonyms, such as Type for DataType, are accepted and rewritten to the model's spelling, and any other unknown name is refused rather than written. A change that would leave an index or a foreign key naming a column that does not exist is refused, and nothing is written.
| Parameter | Required | Description |
|---|---|---|
change_type | Yes | The change, such as add_column, modify_index, remove_fk, set_fulltext or set_description. The command's help lists every change type |
table | Yes | The table to change |
definition | Yes | The change, as JSON, with the property names the table file uses, such as DataType and Nullable for a column |
variant | No | The VariantName of one conditional variant, when more than one declaration shares a name. Without it, a name that matches more than one declaration is refused as ambiguous |
ask-forge apply-change --change-type add_column --table Customers `
--definition <json>
ask-forge apply-change --change-type add_column --table Customers \
--definition <json>
Creates a new table file with the platform's identifier quoting, its default schema, and a primary key generated to match the conventions of the template's existing tables, unless you mark one of your own columns PrimaryKey. Columns use the same property names and the same leniency as schemasmith_apply_change, and any column property can be set inline. On MySQL and MariaDB a table has no schema, because the template's database identification script chooses the database, so the tool writes no Schema and refuses a schema you pass. Inside a schema template, the table is written without a schema, and the engine resolves it for each tenant. A table name longer than the platform allows is refused.
| Parameter | Required | Description |
|---|---|---|
table | Yes | The table's bare name |
schema | No | SQL Server and PostgreSQL only. Defaults to dbo or public |
columns | No | The column definitions, as a JSON array |
prevent_drop | No | Never drop the table for being absent from the package |
variant_name | No | Make the table a conditional variant with this name |
should_apply_expression | No | The SQL condition that decides whether the variant applies to a target |
merge_type | No | Start the table with a data delivery using this merge type |
match_columns | No | The delivery's match columns. Defaults to the primary key |
content_file | No | The delivery's data file, relative to the Table Data folder |
content_encoding | No | Json, the default, or Xml |
description | No | The table's description |
online_apply | No | The table's own Off, Prefer or Require, overriding the deployment's setting |
enable_cdc | No | SQL Server only. Turn change data capture on or off for the table |
cdc_index_name | No | SQL Server only. The unique index change data capture identifies rows by |
ask-forge create-table --table Orders --description "Customer orders"
Writes the tables schemasmith_generate_schema produced into the template, one JSON file per table. Every table is checked before any is written, so one refused table means none are written. A result from an older version of schemasmith_generate_schema, which used property names SchemaSmith does not read, is refused with a request to generate it again. Schema Generation describes the step before this one.
| Parameter | Required | Description |
|---|---|---|
schema | Yes | The generated-schema JSON that schemasmith_generate_schema returned |
product_path | No | The product to write into. Defaults to the loaded product |
template | No | The template to write into. Defaults to the selected template |
ask-forge apply-generated-schema --schema <json>
Renames a table and the file that holds it, and sets OldName so SchemaQuench renames the table at deployment and keeps its data. Every foreign key that points at the table follows the rename, and so do the expressions that name the table, such as a merge filter's subquery. The confirmation and the result list each expression changed, before and after. Script files that mention the table are listed for you to update. The rename is refused before it asks you when a table of the new name already exists. A change of letter case alone counts as a rename, because PostgreSQL treats Customer and customer as two tables.
| Parameter | Required | Description |
|---|---|---|
table | Yes | The current name |
new_name | Yes | The new name |
ask-forge rename-table --table Orders --new-name SalesOrders
Renames a column and sets OldName, so SchemaQuench renames the column at deployment instead of dropping and recreating it. The rename follows the column through the table's indexes, foreign keys, statistics, full-text indexes, data delivery match columns and partition column, through every foreign key elsewhere in the package that references it, and through the table's own expressions, such as check constraints, computed columns and filters. A name is rewritten only where it stands whole, never inside a string or a comment, and the result lists each expression before and after. Script files that mention the column are listed for you to update.
| Parameter | Required | Description |
|---|---|---|
table | Yes | The table |
column | Yes | The current name |
new_name | Yes | The new name |
ask-forge rename-column --table Customers --column Status --new-name State
Save SQL into the package's script folders, and turn a migration plan into files.
Writes a SQL script into one of the package's script folders, such as Before Scripts or Procedures, so that it deploys with the package. It replaces an existing script only when you ask it to, so a save cannot discard a script by accident. A new file name must pass the rule under Names that become files.
| Parameter | Required | Description |
|---|---|---|
content | Yes | The SQL |
folder | Yes | The script folder, such as Procedures |
filename | Yes | The script's file name |
overwrite | No | Replace a script of the same name. Off by default |
ask-forge save-script --folder Procedures --filename Orders.sql --content <sql>
Writes a migration plan from schemasmith_plan_migration to disk: plan.md with the summary, migration.sql with the combined script, and a step-NN-<description>.sql file for each step. Without output_path, the files go in a new timestamped folder under Migrations/ in the product. It never writes over an earlier migration: if any of those files is already in the folder, it refuses before asking you. Each step file's name has every character Windows does not allow in a file name removed or replaced by -, on every operating system. schemasmith_plan_migration is one of the Read-Only Tools.
| Parameter | Required | Description |
|---|---|---|
plan | Yes | The migration plan JSON that schemasmith_plan_migration returned |
output_path | No | The folder to write to. Defaults to a new timestamped folder under Migrations/ |
ask-forge save-migration --plan <json>
Start a package, add templates to it, and remove a template you no longer need.
Creates a new schema package: a folder holding Product.json, with the product's Name, its Platform and an optional MinimumVersion, and an empty Templates/ folder. The platform is required and cannot be changed later; a different platform means rebuilding the package. Without path, the package is created in a folder named after the product, inside the working directory. A folder that already holds a Product.json is refused rather than overwritten. The new product becomes the selected one, so schemasmith_create_template can follow straight away.
| Parameter | Required | Description |
|---|---|---|
name | Yes | The product's name |
platform | Yes | SqlServer, PostgreSQL, MySQL or MariaDb. Cannot be changed later |
path | No | Where to create the package. Defaults to a folder named after the product, in the working directory |
minimum_version | No | The oldest engine version the product supports. A target below it stops at pre-flight |
ask-forge create-product --name Shop --platform PostgreSQL
Adds a template to the selected product: Templates/<name>/Template.json, holding only the template's Name, with the name added to the end of Product.json's TemplateOrder. TemplateOrder is deploy order, so pass first for a template the others depend on. The name is also the folder's name, so it must pass the rule under Names that become files. Until schemasmith_configure_template gives it an identification script, a new template targets nothing.
| Parameter | Required | Description |
|---|---|---|
name | Yes | The template's name, which is also its folder's name |
first | No | Put the template first in TemplateOrder instead of last |
ask-forge create-template --name Shared --first
Deletes a whole template from the selected product: its folder, with every table and script in it, and every TemplateOrder entry that names it. The confirmation says how many tables go with it. The delete is refused, with nothing deleted, when removing the template would leave a foreign key naming a column that no longer exists, or when a file it would delete or change is read-only. A delete never falls back to the selected template; you always name the one to delete.
| Parameter | Required | Description |
|---|---|---|
template | Yes | The template's folder name, in any letter case |
ask-forge delete-template --template Archive
Package a product for deployment, register script folders, and manage script tokens.
Zips the whole product for deployment or hand-off: Product.json, every template or just the one you name, and, by default, the script folders. It packages a product that already exists, where schemasmith_create_product starts one. For a patch that holds only the objects that changed, use schemasmith_run_schema_shears, one of the External Tools.
| Parameter | Required | Description |
|---|---|---|
name | Yes | The ZIP's name, without .zip |
output_path | No | The folder to write to. Defaults to the product folder |
include_scripts | No | Include the script folders. On by default; turn it off for a tables-only package |
template | No | Package this template only |
ask-forge create-package --name shop-1.4.0
Creates a script folder and registers it in Product.json or Template.json with a deployment slot. Leave the slot out and the tool infers it from the folder name. A template that declares no folders deploys the engine's default folder set, so registering the first folder there writes those defaults first, so nothing that deployed before stops deploying. A folder that is already registered is refused, compared without letter case. With parent, the folder is created as a subfolder on disk, without a registration of its own, and deploys with its parent.
| Parameter | Required | Description |
|---|---|---|
folder | Yes | The folder to create |
parent | No | Create the folder inside this existing folder, unregistered |
quench_slot | No | A template folder takes Setup, Before, Objects, BetweenTablesAndKeys, AfterTablesScripts, AfterTablesObjects, TableData or After; a product folder takes Before or After. Inferred from the folder name when left out |
level | No | product or template. Defaults to the current context |
object_type | No | The type of object the folder's scripts create, such as Views or Procedures |
server_to_quench | No | SQL Server product folders only. Primary, Secondary or Both |
should_apply_expression | No | A SQL condition that decides at deployment whether the folder deploys |
ask-forge add-folder --folder Reports --quench-slot After
Manages the {{TokenName}} placeholders SchemaQuench replaces at deployment. list shows the tokens in Product.json and the selected template's Template.json. add, update and remove change one token. scan finds where a token is used, or, in orphans mode, references to tokens that are not defined. suggest looks through scripts for hard-coded values, such as database or server names, that could become tokens. A value can be one of the special token types, named by a prefix such as <*Query*> or <*File*>. The value of a token whose name looks secret is shown as ***. A change that would stop the package loading is refused, and nothing is written.
| Parameter | Required | Description |
|---|---|---|
action | Yes | list, add, update, remove, scan or suggest |
level | No | product or template. Required for add, update and remove |
token_name | No | The token's name, without the braces. Required for add, update and remove, and for scan in token mode |
token_value | No | The token's value. Required for add and update |
scan_mode | No | token, the default, or orphans |
ask-forge manage-tokens --action scan --scan-mode orphans
Set what a product and its templates deploy, and which drops and rebuilds a deployment may make. Each of these tools changes only the properties you supply, and clear: true removes the properties you name instead, so they go back to being inherited or unset.
Sets product-level properties in Product.json: the validation, baseline-validation and version-stamp scripts, the branch-name settings behind the {{BranchName}} token, the template order, the minimum version, whether indexes the package does not declare are dropped, and how SchemaTongs routes check constraints. A template order that names a template the product does not have is refused, and nothing is written.
| Parameter | Required | Description |
|---|---|---|
template_order | No | The template names in deploy order, comma-separated. Only the listed templates deploy |
minimum_version | No | The oldest engine version the product supports |
validation_script | No | SQL run once per server, before any database work, to check a precondition |
baseline_validation_script | No | SQL run once, after the validation script and before any template, to check a precondition |
version_stamp_script | No | SQL run after a successful deployment to record the version on the target |
branch_name_file | No | A file whose contents give the branch name behind {{BranchName}} |
before_branch_name_mask | No | Text trimmed from the front of that file's contents |
after_branch_name_mask | No | Text trimmed from the end of that file's contents |
drop_unknown_indexes | No | Drop indexes on the target that the package does not declare |
check_constraint_style | No | ColumnLevel or TableLevel, how SchemaTongs routes check constraints. SQL Server and PostgreSQL only |
clear | No | Remove the properties you name instead of setting them |
ask-forge configure-product --template-order Shared,Main
Sets template-level properties in the selected template's Template.json: how it finds its target databases, whether it deploys once per schema, how it handles failures and parallel targets, its validation and version-stamp scripts, index handling, and, on SQL Server, which replica it deploys to. schema_identification_script, on SQL Server and PostgreSQL, turns the template into a schema template: the whole template deploys once for each schema the script returns, with that schema available as {{SchemaName}}. The tool refuses that change while an object in the template names a schema of its own, and lists each one.
| Parameter | Required | Description |
|---|---|---|
database_identification_script | No | SQL returning the databases the template deploys to |
identification_database | No | The database that script runs against, when it is not the platform's own |
schema_identification_script | No | SQL Server and PostgreSQL only. SQL returning one schema per row, which makes the template a schema template |
create_schema_if_missing | No | Schema templates only. Create a schema the script returns that does not exist yet |
require_at_least_one_target | No | Fail the run when the identification script returns no databases. On by default |
allow_parallel | No | Schema templates only. Deploy the template's schemas in parallel. On by default; off runs them one at a time |
continue_on_database_failure | No | Carry on with the remaining databases when one fails |
continue_on_schema_failure | No | Schema templates only. Carry on with the remaining schemas when one fails |
skip_if_read_only | No | Skip a read-only target, such as a replica, rather than fail against it |
baseline_validation_script | No | SQL checking a precondition before the template runs |
version_stamp_script | No | SQL run after the template deploys, to record the version on the target |
index_only_table_quenches | No | Apply only index changes to the template's tables |
update_fill_factor | No | SQL Server and PostgreSQL only. Apply fill-factor changes to existing indexes. On by default; such a change rebuilds the index |
drop_unknown_indexes | No | Drop indexes on the target that the package does not declare |
server_to_quench | No | SQL Server only. Primary, Secondary or Both |
cdc_filegroup | No | SQL Server only. The default filegroup for the template's change data capture tables |
cdc_supports_net_changes | No | SQL Server only. Whether change data capture supports net changes, by default |
clear | No | Remove the properties you name instead of setting them |
ask-forge configure-template --database-identification-script "SELECT 'Shop'"
Sets the drop-on-removal flags, Drop*RemovedFromProduct, at the product, template or table tier. They decide whether an object removed from the package is dropped from the target at the next deployment. The flags cascade from product to template to table, and an explicit false at any tier suppresses drops below it. prevent_drop, at the table tier only, protects one table from being dropped by absence.
| Parameter | Required | Description |
|---|---|---|
tier | Yes | product, template or table |
template | No | The template, for the template and table tiers |
table | No | The table, for the table tier |
drop_tables | No | Drop tables removed from the package. Product and template tiers only |
drop_columns | No | Drop columns removed from the package |
drop_foreign_keys | No | Drop foreign keys removed from the package |
drop_check_constraints | No | Drop check constraints removed from the package |
drop_indexes | No | Drop indexes removed from the package |
drop_statistics | No | SQL Server and PostgreSQL only. Drop statistics removed from the package |
drop_exclude_constraints | No | PostgreSQL only. Drop exclude constraints removed from the package |
drop_schema_bound_dependents | No | SQL Server only. Drop the schema-bound dependents of a changed or removed object. Product and template tiers only |
drop_periods | No | MariaDB only, table tier only. Drop application-time periods removed from the package |
prevent_drop | No | Table tier only. Never drop the table for being absent from the package |
clear | No | Remove the flags you name, so the tier inherits from the one above |
ask-forge configure-drop-policy --tier product --drop-columns
Sets the rebuild-trigger policy at the product, template or table tier: NEVER, ALWAYS, or THRESHOLD with a drift threshold, plus an optional trigger when column order no longer matches the definition. Unlike the drop flags, the policy does not cascade field by field. The winning tier's policy applies whole, so a table's policy inherits nothing from the template or product above it.
| Parameter | Required | Description |
|---|---|---|
tier | Yes | product, template or table |
template | No | The template, for the template and table tiers |
table | No | The table, for the table tier |
mode | No | NEVER, ALWAYS or THRESHOLD |
threshold | No | The drift that triggers a rebuild under THRESHOLD |
on_order_mismatch | No | Rebuild when column order no longer matches the definition |
clear | No | Remove the tier's policy, so it inherits from the tier above |
ask-forge configure-rebuild-policy --tier product --mode ALWAYS
Configure a table's data delivery, and the settings that particular engines add to a table, without rewriting the table.
Sets up data delivery on a table: how SchemaQuench merges the table's reference data at deployment. It writes the merge type, match columns, merge filter, trigger handling and content file under the table's DataDelivery key. For Insert/Update and Insert/Update/Delete, match columns you leave out are filled from the primary key. A merge that needs a key is refused when the table declares none: every merge type on SQL Server and PostgreSQL, and Insert/Update/Delete on MySQL and MariaDB. merge_type: None removes the delivery, or, with variant, removes only that variant.
| Parameter | Required | Description |
|---|---|---|
table | Yes | The table |
merge_type | Yes | None, Insert, Insert/Update or Insert/Update/Delete |
match_columns | No | The columns rows are matched on, comma-separated |
merge_filter | No | A SQL WHERE clause limiting which rows are merged |
disable_triggers | No | Disable triggers during the merge |
content_file | No | The data file, relative to the Table Data folder |
content_encoding | No | Json, the default, or Xml |
variant_name | No | The name of a conditional variant of the delivery |
should_apply_expression | No | The SQL condition for that variant. Required on every variant once there are two |
variant | No | An existing variant to replace, or with None to remove |
merge_disable_rules | No | PostgreSQL only. Disable rules during the merge |
merge_update_descendents | No | PostgreSQL only. Carry the merge to descendant tables |
time_zone | No | MySQL and MariaDB only. The time zone the content file's TIMESTAMP values were extracted in, as an offset such as +00:00 |
ask-forge configure-data-delivery --table Countries --merge-type Insert/Update
Sets or removes an existing table's partitioning in one call. The call declares the whole partitioning and replaces what the table had, so a partition you leave out is removed. To add one, pass the existing partitions as well as the new one. On a database where the table already exists, SchemaQuench applies one kind of change: RANGE or LIST partitions appended after the last one, when the last is not MAXVALUE. It refuses a changed method, expression, subpartitioning or HASH/KEY count, and a removed, moved or reordered partition, before touching the table, because repartitioning rewrites every row. A changed partition comment is reported and not applied, and removing the partitioning leaves a deployed table's partitions in place. The SYSTEM_TIME method and its options are MariaDB only and need a system-versioned table.
| Parameter | Required | Description |
|---|---|---|
table | Yes | The table |
method | No | RANGE, LIST, HASH, KEY, their LINEAR and COLUMNS forms, or on MariaDB SYSTEM_TIME. Required unless you remove the partitioning |
expression | No | The partitioning expression, or the column list for KEY and the COLUMNS methods. Required for every method but SYSTEM_TIME |
partition_count | No | How many partitions, for the hash and key methods and SYSTEM_TIME |
partitions | No | The partitions in order, as a JSON array, each with a name, values and comment |
key_algorithm | No | KEY and LINEAR KEY only. 1 or 2, the default |
subpartition_method | No | RANGE and LIST only. Split each partition again by a hash or key method |
subpartition_expression | No | The subpartitioning expression or column list |
subpartition_count | No | Subpartitions in each partition |
interval | No | MariaDB SYSTEM_TIME only. A new history partition per interval, such as 1 MONTH |
starts_at | No | MariaDB SYSTEM_TIME only, with interval. When the first interval starts |
limit | No | MariaDB SYSTEM_TIME only. A new history partition after this many history rows |
auto | No | MariaDB SYSTEM_TIME only, MariaDB 10.9.1 and later. MariaDB adds history partitions as they fill |
remove | No | Remove the table's partitioning |
ask-forge configure-partitioning --table orders --method HASH `
--expression id --partition-count 4
ask-forge configure-partitioning --table orders --method HASH \
--expression id --partition-count 4
Adds, updates or removes an application-time period (PERIOD FOR) on an existing table: a validity window between a start column and an end column, separate from system versioning. MariaDB allows one application-time period per table, so adding a second is refused. Whether a removed period is dropped at deployment is the drop_periods flag of schemasmith_configure_drop_policy, under Product and Template Settings.
| Parameter | Required | Description |
|---|---|---|
table | Yes | The table |
period | Yes | The period's name |
start_column | No | The column holding the start of the window. Needed to add a period |
end_column | No | The column holding the end of the window. Needed to add a period |
remove | No | Remove the named period |
ask-forge configure-periods --table bookings --period valid_period `
--start-column valid_from --end-column valid_to
ask-forge configure-periods --table bookings --period valid_period \
--start-column valid_from --end-column valid_to
Adds, updates or removes one row-level-security policy on an existing table, and turns the table's row-level security on or off. A policy is enforced only while row-level security is on, and row-level security with no policy that grants access hides every row from every role that does not bypass it: superusers, BYPASSRLS roles, and the owner unless the table forces row-level security. A call that leaves policies with row-level security off, or row-level security on with no policies, is written with a warning. A policy is identified by its name and its variant name together.
| Parameter | Required | Description |
|---|---|---|
table | Yes | The table |
policy | No | The policy's name. Required for any policy change |
variant_name | No | The policy's variant name, which with its name identifies it |
command | No | ALL, SELECT, INSERT, UPDATE or DELETE |
permissive | No | PERMISSIVE or RESTRICTIVE |
roles | No | The roles the policy applies to, comma-separated |
using_expression | No | The USING expression: which existing rows are visible |
with_check_expression | No | The WITH CHECK expression: which new rows are allowed |
should_apply_expression | No | The SQL condition for this variant. Required on every variant once there are two |
row_level_security | No | Turn the table's row-level security on or off |
remove | No | Remove the identified policy |
ask-forge configure-policies --table orders --row-level-security
Create the view types that have a definition file of their own.
Creates an indexed view definition file. The definition is the view's SELECT statement; SchemaQuench creates the view WITH SCHEMABINDING, so name each table by its two-part name. The view's stored Name and Schema are written in square brackets, the form SQL Server's own extraction writes, and the file is named with the plain values.
| Parameter | Required | Description |
|---|---|---|
name | Yes | The view's bare name |
definition | Yes | The view's SELECT statement. SchemaQuench adds WITH SCHEMABINDING |
schema | No | Defaults to dbo |
description | No | The view's description |
ask-forge create-indexed-view --name vw_Sales --definition <sql>
Creates a materialized view definition file with its defining query and storage settings. with_data populates the view when it is created. Turn it off to create the view unpopulated and refresh it later, when the defining query is expensive.
| Parameter | Required | Description |
|---|---|---|
name | Yes | The view's bare name |
definition | Yes | The defining query |
schema | No | Defaults to public |
with_data | No | Populate the view when it is created. On by default |
tablespace | No | The view's tablespace |
access_method | No | The table access method behind the view, such as heap |
description | No | The view's description |
ask-forge create-materialized-view --name sales_summary --definition <sql>
These tools write a typed JSON definition into a script folder: Enum Types/, Sequences/, Domain Types/ or Events/. Those folders also hold ordinary .sql scripts, and a new definition lands beside them without touching anything already there.
variant_name becomes part of the file name, so you write a second variant by calling the tool again with another variant_name.Each of the create tools also takes should_apply_expression, variant_name and description.
Creates an enum type (CREATE TYPE ... AS ENUM) in Enum Types/. The order of the labels is the declared order, and it matters, because PostgreSQL sorts an enum by declared position. A label the target does not have yet is added in its declared position at deployment. Removing or reordering a label the target already has is reported rather than applied, because it needs the type dropped and recreated.
| Parameter | Required | Description |
|---|---|---|
name | Yes | The type's bare name |
values | Yes | The labels in order, as a JSON array or a comma-separated list |
schema | No | Defaults to public |
description | No | The type's description |
should_apply_expression | No | The SQL condition for a conditional variant |
variant_name | No | The variant's name, which becomes part of the file name |
ask-forge create-enum-type --name order_status --values draft,active,archived
Creates a sequence (CREATE SEQUENCE) in Sequences/. SchemaQuench creates it, or alters an existing one in place, and never resets its current value. Only the values you supply are written, and the rest keep the engine's defaults. A MariaDB sequence name is not schema-qualified, so schema, persistence_type and description are refused on MariaDB.
| Parameter | Required | Description |
|---|---|---|
name | Yes | The sequence's bare name |
data_type | No | The storage type. Defaults to bigint |
start | No | The value it starts with |
increment | No | The step between values |
min_value | No | The lowest value |
max_value | No | The highest value |
cache | No | How many values are cached |
cycle | No | Wrap around on reaching a bound |
schema | No | PostgreSQL only. Defaults to public |
persistence_type | No | PostgreSQL only. Logged or Unlogged |
description | No | PostgreSQL only. The sequence's description |
should_apply_expression | No | The SQL condition for a conditional variant |
variant_name | No | The variant's name, which becomes part of the file name |
ask-forge create-sequence --name order_no --start 1000
Creates a domain type (CREATE DOMAIN) in Domain Types/, with its NOT NULL, DEFAULT and CHECK constraints. The data type and the collation are set when the domain is created. PostgreSQL cannot alter either, so a later change to either on a domain the target already has is refused, and the deployment fails until the definition matches or a migration script recreates the domain. The default can be changed in place.
| Parameter | Required | Description |
|---|---|---|
name | Yes | The type's bare name |
data_type | Yes | The underlying type, such as varchar(2) |
not_null | No | Reject NULL |
default | No | The default expression |
collation | No | The collation, when it differs from the base type's |
check_constraints | No | The check constraints, as a JSON array, each with a name and an expression |
schema | No | Defaults to public |
description | No | The type's description |
should_apply_expression | No | The SQL condition for a conditional variant |
variant_name | No | The variant's name, which becomes part of the file name |
ask-forge create-domain-type --name us_state --data-type "varchar(2)"
Creates a scheduled event (CREATE EVENT) in Events/. An event has no schema, so its name is its whole identity. A recurring event, EVERY, the default, takes an interval and optional start and end bounds; a one-shot event, AT, takes a run time. A field that belongs to the other kind is refused rather than dropped.
| Parameter | Required | Description |
|---|---|---|
name | Yes | The event's name |
definition | Yes | The SQL the scheduler runs |
schedule_type | No | EVERY, the default, or AT |
interval | No | How often an EVERY event runs, such as 1 DAY. Required for EVERY |
execute_at | No | When an AT event runs. Required for AT |
starts | No | When an EVERY event starts |
ends | No | When an EVERY event ends |
status | No | ENABLE, DISABLE or DISABLE ON SLAVE |
preserve | No | Keep the event after its last run |
time_zone | No | The time zone the schedule's times are read in |
sql_mode | No | The sql_mode the event body runs under |
description | No | The event's description |
should_apply_expression | No | The SQL condition for a conditional variant |
variant_name | No | The variant's name, which becomes part of the file name |
ask-forge create-event --name purge_logs --definition <sql> --interval "1 DAY"
Renames one of these objects: a PostgreSQL enum type or domain type, a PostgreSQL or MariaDB sequence, or a MySQL or MariaDB event. It writes the new Name into the definition and moves the file to match, for every conditional variant of the object unless variant narrows it to one. Calling a create tool again with the new name would leave two objects instead of one. These objects carry no OldName, so a deployment after the rename creates the new object and leaves the old one in place. For an event, SchemaQuench's DropEventsRemovedFromProduct setting, off by default (drop_removed_events in schemasmith_run_schema_quench's options), can remove it; otherwise drop the old object with a migration script.
| Parameter | Required | Description |
|---|---|---|
object_type | Yes | enum_type, sequence, domain_type or event |
name | Yes | The current name, without a schema |
new_name | Yes | The new name, without a schema |
schema | No | The current schema, for the PostgreSQL objects. Defaults to public |
variant | No | Rename only the variant with this VariantName |
ask-forge rename-modeled-object --object-type enum_type `
--name order_status --new-name order_state
ask-forge rename-modeled-object --object-type enum_type \
--name order_status --new-name order_state
Free schema-as-code for SQL Server, PostgreSQL, MySQL, and MariaDB.
The source is on GitHub for anyone to read.
Get Started on GitHub