SchemaSmith Documentation

Generation Tools

9 tools for migration scripts, schema generation, file output, and configuration management.

Ask Forge Generation Tools

Assistant Trust Level

Ask Forge generation tools use AI to create new content based on your schema. They produce migration scripts, schema designs, change suggestions, and configuration updates — all presented for your review before any action is taken.

Generated content is never applied automatically. Scripts and plans are output as text or saved to files you specify. This keeps you in full control while benefiting from AI-powered analysis.

Generation tools require the Assistant trust level or higher. They build on the read-only capabilities of Tier 1. None of these tools require confirmation — they are available immediately at the Assistant trust level.

All 9 tools use the forge_ prefix when accessed through the MCP server (e.g., forge_generate_migration). In the CLI and REPL, use kebab-case (e.g., generate-migration).

Migration Planning

Generate migration scripts and analyze the impact of proposed schema changes.

generate-migration MCP: forge_generate_migration

Generate a SQL migration script for a schema change — nullability fixes, foreign key additions, or data type changes. Requires an active template context. The tool validates that the target table and column exist in the current template before generating the script.

Parameters
ParameterRequiredDescription
--change-typeYesType of change: nullability, add_fk, or change_type
--tableYesTarget table name
--columnYesTarget column name
--default-valueNoDefault value for NULL cleanup (required for nullability changes)
--ref-tableNoReferenced table (required for add_fk)
--ref-columnNoReferenced column (required for add_fk)
--new-typeNoNew data type (required for change_type)

Example:

ask-forge generate-migration --change-type nullability --table Customers \
  --column Email --default-value "unknown@example.com"

Returns: Platform-specific SQL migration script (T-SQL, PL/pgSQL, or MySQL dialect) with proper dependency ordering.

suggest-changes MCP: forge_suggest_changes

Analyze a proposed schema change and get recommendations, risk assessment, and migration scripts. Requires an active template context. Returns a risk level (Low, Medium, High, Critical), potential issues, suggested actions with priority ordering, and Forge's assessment.

Parameters
ParameterRequiredDescription
--change-typeYesType of change: nullability, add_fk, change_type, or add_unique
--tableYesTable name
--columnNoColumn name (required for most changes)
--ref-tableNoReferenced table (for add_fk)
--ref-columnNoReferenced column (for add_fk)
--new-typeNoNew data type (for change_type)
--columnsNoComma-separated column names (for add_unique)

Example:

ask-forge suggest-changes --change-type add_unique --table Users \
  --columns "Email,TenantID"

Returns: Risk level, potential issues, prioritized suggested actions, and Forge's assessment of the change.

Schema Generation

Generate SchemaSmith-format JSON schema definitions from blueprint specifications.

generate-schema MCP: forge_generate_schema

Generate platform-specific table JSON from a SchemaBlueprint specification. Accepts a JSON blueprint describing the desired schema and produces table definitions for the target platform. If a template context is active, the tool detects existing conventions (naming, data types) and applies them to the generated output.

Use apply-generated-schema (Tier 3) to write the results to disk.

Parameters
ParameterRequiredDescription
--blueprintYesJSON string containing SchemaBlueprint spec with name, tables, columns, relationships, and options
--platformNoOverride platform (MSSQL, PostgreSQL, MySQL). Defaults to current context platform

Example:

ask-forge generate-schema \
  --blueprint '{"name":"Inventory","tables":[{"name":"Warehouses",
    "columns":[{"name":"ID","type":"int","primaryKey":true},
    {"name":"Name","type":"string","maxLength":100}]}]}'

Returns: Complete SchemaSmith JSON schema with packages, templates, tables, columns, indexes, and relationships.

File Output

Save generated scripts and migration plans to the file system.

save-script MCP: forge_save_script

Save a SQL script to a script folder in the current product or template. Requires an active product context. The script folder must already exist in the product or template definition. If the filename does not end with .sql, the extension is appended automatically.

Parameters
ParameterRequiredDescription
--contentYesSQL script content to save
--folderYesScript folder name (e.g., Migrations, Before)
--filenameYesScript filename (e.g., UpdateCustomerEmail.sql)
--overwriteNoWhether to overwrite if file exists (default: false)

Example:

ask-forge save-script --folder Migrations \
  --filename "AddIndexOnEmail.sql" \
  --content "CREATE INDEX IX_Users_Email ON Users(Email);"

Returns: Confirmation with the file path and size of the saved script.

save-migration MCP: forge_save_migration

Save a migration plan to disk as a markdown summary and individual SQL script files. Takes a migration plan JSON (typically from the plan-migration read-only tool) and writes a plan.md summary, a combined migration.sql script, and individual step-NN-<description>.sql files for each step.

Parameters
ParameterRequiredDescription
--planYesMigration plan JSON (from plan_migration tool output)
--output-pathNoCustom output directory (default: Migrations/<timestamp> under product path)

Example:

ask-forge save-migration --plan '<migration-plan-json>' \
  --output-path ./migrations/v2-upgrade

Returns: Confirmation with directory path, file list, and total size of saved migration artifacts.

Configuration Management

Manage database connections and SchemaSmith tool paths stored in the config file. Environment variables and explicit CLI parameters take precedence over stored values.

set-connection MCP: forge_set_connection

Set or update the database connection for a platform. Each platform (mssql, postgresql, mysql) has one connection with individual fields. Properties can be set or updated incrementally — existing fields are preserved when updating.

Parameters
ParameterRequiredDescription
--platformYesDatabase platform: mssql, postgresql, or mysql
--serverNoServer/host (required when creating a new connection)
--portNoPort number (defaults: MSSQL 1433, PostgreSQL 5432, MySQL 3306)
--databaseNoDatabase name
--userNoUser ID
--passwordNoPassword

Example:

ask-forge set-connection --platform postgresql --server localhost \
  --port 5432 --database myapp --user postgres --password secret

Returns: Confirmation with the updated connection settings for the specified platform.

set-tool-path MCP: forge_set_tool_path

Set the path to a SchemaSmith tool (SchemaTongs, DataTongs, or Quench) for a platform. The path can be a full filesystem path, a bare executable name resolved via PATH, or a path containing environment variables (%PROGRAMFILES%, ${HOME}). Variable references are stored as-is and expanded at runtime.

Parameters
ParameterRequiredDescription
--platformYesDatabase platform: mssql, postgresql, or mysql
--toolYesTool name: schemaTongs, dataTongs, or quench
--pathYesPath to the tool executable

Example:

ask-forge set-tool-path --platform postgresql --tool quench \
  --path postgres-quench

Returns: Confirmation with the stored tool path for the specified platform and tool.

clear-connection MCP: forge_clear_connection

Remove the database connection for a platform. Deletes all stored connection fields for the specified platform from the configuration file.

Parameters
ParameterRequiredDescription
--platformYesDatabase platform to clear: mssql, postgresql, or mysql

Example:

ask-forge clear-connection --platform postgresql

Returns: Confirmation that the connection was removed.

clear-tool-path MCP: forge_clear_tool_path

Remove a tool path configuration for a platform. After clearing, the tool will need to be found via PATH or environment variables at runtime.

Parameters
ParameterRequiredDescription
--platformYesDatabase platform: mssql, postgresql, or mysql
--toolYesTool name to clear: schemaTongs, dataTongs, or quench

Example:

ask-forge clear-tool-path --platform mssql --tool schemaTongs

Returns: Confirmation that the tool path was removed.

Related Documentation