Skip to content
pre-alpha — the TypeScript API may still shift. The SQL won't.

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:

Terminal window
npx sqlfu check

If sqlfu is installed in your project, package-manager exec commands work too:

Terminal window
pnpm exec sqlfu migrate

Start the local backend for the hosted Admin UI.

Terminal window
npx sqlfu

The command prints sqlfu ready at https://sqlfu.dev/ui. The UI shell is hosted, but the database backend stays on your machine.

Report the important repo and database mismatches:

  • definitions.sql not 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.

Create a migration file from the difference between replayed migrations and definitions.sql.

Terminal window
npx sqlfu draft

sqlfu 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.

Apply pending migrations to the configured database.

Terminal window
npx sqlfu migrate

Migrations run in filename order and are recorded in the migration-history table configured for your project.

Generate TypeScript wrappers and query metadata from checked-in .sql files.

Terminal window
npx sqlfu generate

By 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.

Rewrite .sql files with sqlfu’s formatter.

Terminal window
npx sqlfu format "sql/**/*.sql" definitions.sql

The command accepts file paths, directories, and simple glob patterns.

Update the live database directly from definitions.sql.

Terminal window
npx sqlfu sync

This is a local-development tool. Production databases should normally move by reviewed migrations and npx sqlfu migrate.

List migration files that have not been applied to the configured database.

List migrations recorded in the configured database.

Resolve a migration target by name or prefix.

Move both live schema and migration history to an exact target migration.

Rewrite migration history to an exact target without changing live schema.

Create a starting sqlfu.config.ts.

Stop the local sqlfu backend process on the default port.

Print the resolved project config. This is mostly useful while debugging config loading.