Table of Contents

Schemas

Foundry's schema commands cover the full Velocity schema lifecycle: building objects in a database, loading existing structures from a database, applying incremental updates, and working with schema and database definition files.

Build

The foundry build command creates schema objects (tables, views, indexes) in a connected database from a definition file.

foundry build schema

Builds all objects defined in a schema definition file into the target database schema.

foundry build schema [options]
Option Short Description
--datasource <FILE> -d Datasource JSON file
--conn <STRING> -c ADO.NET connection string
--db <TYPE> -b Database engine type
--file <FILE> -f Path to the schema definition file (XML, JSON, or YAML)
--drop Drop existing objects before building
--ignore Continue if an object already exists
--transaction Wrap all DDL in a transaction (rolls back on error)
--log-config <FILE> -L Log configuration file
--verbose -v Print SQL as it executes

Examples:

# Build from an XML definition using a datasource file
foundry build schema --datasource connection.json --file schemas/customers.xml

# Drop and rebuild with a transaction
foundry build schema \
  --datasource PostgreSQL_17.6.json \
  --file schemas/public.json \
  --drop --ignore --transaction

# Using an inline connection string
foundry build schema \
  --conn "Server=localhost;Database=mydb;User Id=sa;Password=pass" \
  --db SQLServer \
  --file schemas/dbo.xml

foundry build database

Builds all schemas defined in a database definition file.

foundry build database [options]

Accepts the same options as foundry build schema. The --file argument should point to a database-level definition file that references multiple schemas.

Examples:

foundry build database --datasource connection.json --file mydb.xml --drop

foundry build database \
  --conn "Server=localhost;Database=mydb;User Id=sa;Password=pass" \
  --db SQLServer \
  --file mydb.xml --drop --ignore --transaction

Load

foundry load reads the structure of a live database and writes it as a Velocity definition file. Use this to capture the current state of a database as a baseline, or after making manual schema changes.

foundry load schema

Reads a named schema from the database and writes its definition to a file.

foundry load schema [options]
Option Short Description
--datasource <FILE> -d Datasource JSON file
--conn <STRING> -c ADO.NET connection string
--db <TYPE> -b Database engine type
--schema <NAME> -s Name of the schema to load
--out <FILE> -o Output file path
--format <FORMAT> -F Output format: Xml, Json, Yaml (default: Xml)

Examples:

foundry load schema --datasource connection.json --schema dbo --out schemas/dbo.xml

foundry load schema \
  --datasource PostgreSQL_17.6.json \
  --schema public --out schemas/public.json

foundry load database

Reads the full database structure and writes a database-level definition file. You can scope the load to specific schemas using --schema.

foundry load database [options]
Option Short Description
--datasource <FILE> -d Datasource JSON file
--conn <STRING> -c ADO.NET connection string
--db <TYPE> -b Database engine type
--schema <NAMES> -s Comma-separated schema names to include (all if omitted)
--out <FILE> -o Output file path
--format <FORMAT> -F Output format: Xml, Json, Yaml (default: Xml)

Examples:

foundry load database --datasource connection.json --out mydb.xml

# Load only specific schemas
foundry load database \
  --datasource SqlServer_16.0.json \
  --schema dbo,audit --out mydb.yaml

Update

foundry update schema applies the differences between a definition file and the live schema, adding new columns, indexes, and objects as needed.

foundry update schema [options]
Option Short Description
--datasource <FILE> -d Datasource JSON file
--conn <STRING> -c ADO.NET connection string
--db <TYPE> -b Database engine type
--file <FILE> -f Path to the schema definition file
--force Apply destructive changes (column drops, type changes) without confirmation
--log-config <FILE> -L Log configuration file
--verbose -v Print SQL as it executes
Warning

Without --force, update avoids destructive changes such as dropping columns or altering data types. Use --force with caution in production environments.

Examples:

foundry update schema --datasource connection.json --file schemas/dbo.xml

foundry update schema \
  --datasource PostgreSQL_18.1.json \
  --file schemas/public.json --force

Definition

The foundry definition command works with schema and database definition files without requiring a live database connection — except for the validate subcommand.

All definition operations work on either schema or database scope:

foundry definition schema  <subcommand> [options]
foundry definition database <subcommand> [options]

read

Reads a definition file and prints a summary to the console.

Option Description
--file <FILE> Path to the definition file
--format <FORMAT> File format hint: Xml, Json, Yaml
--verbose Print full detail rather than a summary
foundry definition schema read --file schemas/dbo.xml
foundry definition database read --file mydb.json --verbose

convert

Converts a definition file from one format to another (XML ↔ JSON ↔ YAML).

Option Description
--file <FILE> Source file
--format <FORMAT> Source format hint
--out <FILE> Output file path
--out-format <FORMAT> Output format (inferred from --out extension if omitted)
foundry definition schema convert --file schemas/dbo.xml --out schemas/dbo.json
foundry definition database convert --file mydb.yaml --out mydb.xml

compare

Compares two definition files and reports differences.

Option Description
--file1 <FILE> First definition file
--format1 <FORMAT> Format hint for file 1
--file2 <FILE> Second definition file
--format2 <FORMAT> Format hint for file 2
foundry definition schema compare --file1 schemas/dbo_v1.xml --file2 schemas/dbo_v2.xml
foundry definition database compare --file1 mydb_v1.xml --file2 mydb_v2.xml

validate

Validates a definition file against a live database, checking that all objects in the file match what exists in the database.

Accepts all connection options in addition to:

Option Description
--file <FILE> Path to the definition file
--format <FORMAT> File format hint
foundry definition schema validate --datasource connection.json --file schemas/dbo.xml

foundry definition database validate \
  --conn "Server=localhost;Database=mydb;User Id=sa;Password=pass" \
  --db SQLServer \
  --file mydb.xml