CLI
The sqlfu CLI is the project control surface. It reads sqlfu.config.ts, works
against the SQL files in your repo, and starts the local backend used by the
hosted Admin UI.
Most commands can be run through npx:
npx sqlfu checkIf sqlfu is installed in your project, package-manager exec commands work too:
pnpm exec sqlfu migrateCommon commands
Section titled “Common commands”npx sqlfu
Section titled “npx sqlfu”Start the local backend for the hosted Admin UI.
npx sqlfuThe command prints sqlfu ready at https://sqlfu.dev/ui. The UI shell is hosted,
but the database backend stays on your machine.
npx sqlfu check
Section titled “npx sqlfu check”Report the important repo and database mismatches:
definitions.sqlnot matching replayed migrations- pending migrations
- applied migrations that no longer match the repo
- live schema drift
This is the safest command to run when you are not sure what the next migration command should be.
npx sqlfu draft
Section titled “npx sqlfu draft”Create a migration file from the difference between replayed migrations and
definitions.sql.
npx sqlfu draftsqlfu shows the drafted SQL before writing the file. The diff is best-effort: review the generated migration the same way you would review a hand-written one.
npx sqlfu migrate
Section titled “npx sqlfu migrate”Apply pending migrations to the configured database.
npx sqlfu migrateMigrations run in filename order and are recorded in the migration-history table configured for your project.
npx sqlfu generate
Section titled “npx sqlfu generate”Generate TypeScript wrappers and query metadata from checked-in .sql files.
npx sqlfu generateBy default, type generation reads definitions.sql, so it does not need a live
database. Change generate.authority when generated types should follow
replayed migrations, migration history, or live schema instead.
npx sqlfu format
Section titled “npx sqlfu format”Rewrite .sql files with sqlfu’s formatter.
npx sqlfu format "sql/**/*.sql" definitions.sqlThe command accepts file paths, directories, and simple glob patterns.
npx sqlfu sync
Section titled “npx sqlfu sync”Update the live database directly from definitions.sql.
npx sqlfu syncThis is a local-development tool. Production databases should normally move by
reviewed migrations and npx sqlfu migrate.
History tools
Section titled “History tools”npx sqlfu pending
Section titled “npx sqlfu pending”List migration files that have not been applied to the configured database.
npx sqlfu applied
Section titled “npx sqlfu applied”List migrations recorded in the configured database.
npx sqlfu find <target>
Section titled “npx sqlfu find <target>”Resolve a migration target by name or prefix.
npx sqlfu goto <target>
Section titled “npx sqlfu goto <target>”Move both live schema and migration history to an exact target migration.
npx sqlfu baseline <target>
Section titled “npx sqlfu baseline <target>”Rewrite migration history to an exact target without changing live schema.
Project tools
Section titled “Project tools”npx sqlfu init
Section titled “npx sqlfu init”Create a starting sqlfu.config.ts.
npx sqlfu kill
Section titled “npx sqlfu kill”Stop the local sqlfu backend process on the default port.
npx sqlfu config
Section titled “npx sqlfu config”Print the resolved project config. This is mostly useful while debugging config loading.