Lone Badger Tech

Command reference

Every bsm command and option (version 0.3.0).

CommandOptionsDoes
bsm init[--provider sqlserver|postgresql]Create bsm.yaml, bsm.plan, folders and .gitattributes.
bsm add <name>[-r|--requires a b] [-n|--note text] [--notx] [--irreversible]Scaffold changes/<name>/ and append it to the plan.
bsm add <name> --from-diff[--shadow-env env] [--keep-shadow] [--exclude schema.name…] [--dry-run] [--no-record] [-r …] [-n …]Generate deploy.sql and revert.sql from schema edits made in the environment's database, compared with a shadow database built from the plan; records the change as applied there.
bsm tag <name>Tag the last change in the plan (use as @name).
bsm plan checkValidate plan, folders, lint and variable definitions. No database.
bsm plan showChanges with script hashes and chain ids; the plan head. No database.
bsm status[--exit-code]Plan versus database: pending, applied, edited, orphans, certified. --exit-code returns 3 when not up to date.
bsm deploy[--to change|@tag] [--dry-run] [--script file] [--ordering dependency|strict] [-y]Provision environment resources, deploy pending changes, apply changed repeatables, record a schema fingerprint. --script writes a reviewable SQL file instead.
bsm revert--to x | --last n | --all | --repeatable name… [--dry-run] [-y] [--allow-variable-drift]Revert with the scripts stored at deploy time; --repeatable restores a repeatable's previous definition.
bsm rebase--to x [-y] [--allow-variable-drift]Revert to x, then deploy to the head.
bsm rework <change>[--as name] [-n|--note text]Add a change that supersedes a deployed one: a copy of its deploy script to edit, with a revert that restores it.
bsm repair[changes…] | --all [--reason text] [--dry-run] [-y]Accept edits to deployed changes without running SQL; re-chains and re-certifies the journal.
bsm bundle create[-o file] [--no-config]Write a hash-verified bundle of the project. No database.
bsm bundle verify <file>Check every file in a bundle against its manifest. No database.
bsm diff-schema[--against env] [--exit-code] [--script file]Schema differences: live versus the schema recorded after the last deploy, or versus another environment. --exit-code returns 3 when they differ; --script writes SQL that turns this database into the other.
bsm verifyHashes versus working copy, rendered-SQL drift, verify scripts (rolled back), schema drift. Exit 1 on problems.
bsm log[-n|--limit 50]Deploy, revert, fail, repeatable and resource events, newest first.
bsm baseline--to x | --from flyway|dbup|grate|roundhouse|sqitch [--journal schema.table] [--skip-checksums] [-y]Record changes as applied without running them: up to x, or as far as the old tool's journal in the database says (with repeatables it already applied).
bsm import flyway <folder>[--config file] [--location dir…] [--provider sqlserver|postgresql] [--dry-run]Convert a Flyway project into a new bsm project (written to -C). No database.
bsm import dbup <folder>[--file-names] [--run-always glob…] [--no-variables] [--var name=value…] [--dry-run]Convert DbUp scripts into a new bsm project (written to -C). No database.
bsm import grate <folder>[--folder key=name…] [--environment name…] [--ignore-directory-names] [--no-tokens] [--var name=value…] [--dry-run]Convert a grate or RoundhousE scripts folder into a new bsm project. No database.
bsm import sqitch <folder>[--engine name] [--provider …] [--dry-run]Convert a Sqitch project into a new bsm project. No database.
bsm varsEvery variable for the environment: value, source, description.
bsm render <name>[-k|--kind deploy|revert|verify]Print a change or repeatable exactly as it would run.
bsm env listEnvironments and templates.
bsm env showThe selected environment, merged, secrets masked.
bsm env statusEnvironment resources (Always Encrypted keys) versus the database.
bsm env provision[--dry-run] [--allow-destructive] [-y]Create or rotate environment resources without deploying changes.
bsm auth clearForget saved Entra sign-ins.
bsm doctorConfiguration, Entra token, connection, server facts, journal, resources.

Global options

OptionMeaning
-C, --project <dir>Project folder (default: current folder)
-e, --env <name>Environment (default: BSM_ENV, then defaultEnvironment, then the only one)
--var name=valueScript variable; repeatable; overrides bsm.yaml
--connection-string "..."Connect exactly here for this run
--bundle <file>Take the plan and scripts from a verified bundle instead of the project folder (and bsm.yaml too, when bundled)
--claim-environmentAccept a database recorded under another environment and re-record it
--jsonMachine-readable output on stdout (warnings go to stderr)
-v, --verboseServer messages (PRINT), fingerprints, tunnel details
--no-colorNo ANSI colors; NO_COLOR and redirected output also turn them off
--version, -hVersion; help for any command

Exit codes

CodeMeaning
0Success
1Failure: a script error, a problem found by plan check or verify, a refused action, bad configuration, or a command-line usage error
3status --exit-code: not up to date; diff-schema --exit-code: schemas differ

Environment variables

VariableMeaning
BSM_ENVDefault environment
BSM_AUTHORAuthor written by bsm add (default: OS user)
BSM_HOMEWhere saved sign-ins live (default ~/.bsm)
NO_COLORDisable colors

Confirmation

Revert, rebase, repair, baseline and destructive provisioning ask for confirmation. In a protected environment, so does deploy, and you must type the environment name. Non-interactive runs (redirected input, --json) fail instead of hanging unless you pass --yes.

JSON output

bsm status -e prod --json | jq '.certified, .databaseHead'
bsm log --json -n 20