nschema fmt
Reformat your .sql DDL files to a canonical layout — the analogue of terraform fmt.
Formatting is gentle: it normalises layout (one blank line between statements, one
member per line indented two spaces inside CREATE TABLE and config blocks, canonical
(/) placement) while preserving your content verbatim — keyword casing, member order,
expression spelling, multi-line view/routine/script bodies, and every comment. It is
idempotent, and deliberately does not rewrite content the way import
canonicalises it.
nschema fmt # format every .sql file under the current directorynschema fmt ./schemas/users.sql # format a single filenschema fmt --check # CI: fail if anything is unformattedcat users.sql | nschema fmt - # format stdin to stdoutnschema fmt [path] rewrites a single .sql file, or every .sql file found recursively
under a directory, in place, and lists the files it changed. path defaults to the current
directory.
Options
Section titled “Options”--check— write nothing; list the files that need formatting and exit2if any do (errors exit1). For CI.nschema fmt -— read DDL from stdin and write the formatted result to stdout, for editor integration.
Nothing — it only reads and writes files.