Command Line Interface#
SQLSpec includes a CLI for managing migrations and inspecting configuration. Use it when you want a fast, explicit workflow without additional tooling.
Every command needs a configuration reference. Pass it with --config, set
SQLSPEC_CONFIG, or record it in [tool.sqlspec] -- see
Pointing the CLI at your configuration for the details.
Core Commands#
sqlspec --config database:database_config show-config
sqlspec --config database:database_config init --no-prompt
sqlspec --config database:database_config create-migration -m "add users" --no-prompt
sqlspec --config database:database_config upgrade --no-prompt
sqlspec --config database:database_config downgrade --no-prompt
sqlspec --config database:database_config show-current-revision
Common Options#
--bind-keytargets a specific database configuration.--no-promptskips confirmation prompts.--formatselects SQL vs Python migration files.--validate-configreports each configuration and whether it is async-capable.--use-loggeremits migration output via structured logger.--no-echodisables console output for migration commands.--summaryemits a single summary log entry when logger output is enabled.
Tips#
show-configverifies the CLI resolved the configuration you expected before you run anything that touches the database.Run
sqlspec --helpto see global options.Run
sqlspec upgrade --helpto see command-specific migration options.