Durable Objects give each instance its own private SQLite database. A code deploy updates the Worker bundle, but existing Durable Object storage stays whatever that instance has applied so far. sqlfu handles this by runningDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/iterate/sqlfu/llms.txt
Use this file to discover all available pages before exploring further.
migrate() synchronously in the constructor — before the first request is served.
Project shape
Give each Durable Object class its own sqlfu project:--config explicitly:
Config
Durable Object storage is not available to the Node CLI as a simple local file, so the typical Durable Object config omitsdb. sqlfu uses .sqlfu/app.db as a local authoring database for commands that need one, while draft and generate still read from definitions.sql and migration files.
sqlfu.config.ts
generate.sync: true matters because Durable Object SQLite is synchronous. Generated query wrappers accept a SyncClient and return rows directly instead of promises.
Author schema and queries
Durable Object runtime
Importmigrate from the generated module and call it in the constructor:
counter.ts
How runtime migrations work
migrate() is synchronous and idempotent. It checks the sqlfu_migrations table in that object’s private SQLite database, skips migrations already recorded there, and applies only the files that are missing from the bundle.
Because the Durable Object migrator is synchronous, calling migrate(this.client) directly in the constructor is enough — the object does not serve a request before the constructor returns, so no await or deferred initialization is needed.
What happens if an applied migration is missing
sqlfu treats a missing applied migration as a migration-history integrity problem. If a Durable Object instance has recordedsqlfu_migrations rows for migrations that are no longer present in the generated bundle, migrate() fails with a deleted-applied-migration error before applying any newer migrations.
This is intentional. sqlfu does not synthesize missing SQL at runtime. Runtime schema changes still need reviewable migration files because renames, destructive changes, and backfills are product decisions. Use
sqlfu draft to turn definitions.sql changes into migration files before deploying.Generated migration bundle
sqlfu generate emits migrations/.generated/migrations.ts when migrations is configured. This file is a plain TypeScript bundle containing your migration SQL as string literals — no filesystem reads at runtime. Commit both migrations/*.sql and the generated bundle. The migrate export is what your Durable Object calls.
Read next
Migration model
The four authorities, pending migrations, history drift, and what each command mutates.
Cloudflare D1 guide
Connect sqlfu to a deployed D1 database for CLI and UI access.
Adapters reference
The Durable Object adapter snippet and full compatibility matrix.
Getting started
The base SQL → draft → generate workflow.