retrofit
Schema evolution CLI: an append-only oplog of DDL operators that
materializes into canonical SQL.
Bootstrap a new project:
retrofit init # write retrofit.toml + .gitattributes
retrofit schema create users # register a schema and create its oplog
retrofit op add CreateTable people # author your first op
retrofit snapshot # emit canonical DDL
Bootstrap from an existing schema:
retrofit init
retrofit import path/to/source.sql --schema users # lazy-creates if unregistered
Run any subcommand with --help for its flags, or --help-all for its
extended reference. `retrofit help --all` prints the full reference for
every command at once.
Usage:
retrofit [command]
Available Commands:
completion Generate the autocompletion script for the specified shell
data Work with the data corpus
drift Reconcile an oplog with an out-of-band `.sql`
help Help about any command
identify Report which cut a pg_dump --schema-only is at, and how it has diverged
import Import one or more `.sql` files into an oplog
init Initialize a new retrofit project
migrate Emit a one-way migration script between two cuts
op Edit the oplog
ops Run bulk maintenance over the oplog
reconcile Close concurrent forks in the oplog by rebasing onto a linear tail
schema Manage registered schemas
snapshot Emit canonical DDL for the materialized schema
validate Validate retrofit.toml, project layout, and the oplog
Flags:
--as string output mode: text | json (default "text")
-C, --chdir string treat <dir> as the working directory for the entire run
--config string retrofit.toml path (overrides discovery; also accepts $RETROFIT_CONFIG)
-f, --file string oplog file path; selects a registered [[schema]] path (overrides discovery)
-h, --help help for retrofit
--help-all show extended help (vocabulary, semantics, caveats)
--no-consolidate render every advisory occurrence instead of collapsing repeats
-q, --quiet count suppress the advisory tier on stderr; stack (-qq) to drop it whole (errors and results still print)
-v, --verbose reveal info-tier advisories on stderr
--version version for retrofit
Use "retrofit [command] --help" for more information about a command.
Docs: https://docs.retrofit.sh/current/retrofit --help-all adds:
Extended help:
Typical authoring workflow:
retrofit init
retrofit schema create users
retrofit op add CreateTable people
retrofit op add AddColumn people id bigint identity=by_default
retrofit op add AddColumn people email text not_null=true
retrofit op add AddPrimaryKey people --column people.id name=people_pkey
retrofit op seal # freeze the unsealed tail
retrofit snapshot # emit canonical DDL
Notes on the bootstrap recipe:
`schema create` mints the schema's CreateSchema op and registers
the schema in retrofit.toml. `import` adopts that op and mints
the rest of the prefix. To extend a schema already imported from one
`.sql` with another, run `import` again: it extends a
populated oplog by default; to re-bootstrap from a different
`.sql` and discard prior content, pass `--force`.
Per-command extended help is available via `retrofit <cmd> --help-all`
(e.g. `retrofit import --help-all` for the main in-vocabulary statements).