Releases: eagerpatch/durable-db
durable-db@0.0.3
Patch Changes
-
96a3ed0: Better failure modes for dev and deploy:
- A pending migration that fails with "already exists" (storage holds tables the
__migrationsjournal doesn't track — typically renamed/regenerated migration files) now raisesMigrationSchemaConflictErrorwith recovery guidance (db resetin dev, baseline the journal in production) instead of a raw SQLITE_ERROR. - When the storage backend rejects a PITR restore as unsupported (local workerd hands out bookmarks but doesn't implement restore), PITR is disabled for that instance and the miss is logged at debug level — no more error-level "PITR restore failed" line that reads like a second failure.
- The Vite plugin no longer crashes the dev server on the first run of a fresh project: its own bootstrap write of the dev epoch no longer bounces through the cache watcher as a full reload, and reload sends skip hot channels whose transport isn't connected yet (e.g. @cloudflare/vite-plugin before its module-runner WebSocket exists).
- Production builds now fail when wrangler.jsonc is missing Durable Object bindings for discovered databases and
patchWranglerConfigis off — previously the build succeeded and the deploy shipped a worker with no DO bindings. Dev still warns, and wrangler.toml projects still warn (the check can't parse toml).
- A pending migration that fails with "already exists" (storage holds tables the
durable-db@0.0.2
Patch Changes
-
a70a8b2: Fix four bugs found while dogfooding, plus live dev-state reloading:
-
Same-file actions work:
action()definitions in the same file asdefineDatabase()are now transformed into RPC stubs like separate action files, instead of throwing "Action called without transformation" at runtime. -
Schema loading fails loudly:
db push/generate/status/validatenow error (exit 1) when declared schema tables can't be loaded — inline table definitions, unresolvable schema imports, build failures, or missing exports — instead of silently reporting "no changes". -
Text date columns round-trip verbatim:
text()columns holding ISO date strings no longer come back asnullover the action RPC.DateSerializePluginonly deserializes the exactYYYY-MM-DD HH:MM:SSformat its write path produces, never double-appends timezone markers, and is schema-aware viacreateDrizzlePlugins(only Drizzle date-typed columns convert toDate). -
db resetactually gives fresh databases: the dev epoch is now baked into generated stubs via thevirtual:durable-db/__devEpochmodule (applyDevEpoch(key), identity in production builds). A reset's epoch bump rotates every database to a brand-new DO instance on the next request — no storage deletion, dev server can keep running. New opt-indb reset --purge-local-storagedeletes the orphaned instances under.wrangler/state/v3/do. -
Live CLI integration: the Vite dev server watches durable-db's dev cache, so
db resetanddb pushtake effect immediately (epoch + embedded dev migrations reload) without restarting. -
Flat
dbbinary: the standalone CLI is nowdb push/db reset/… instead of the accidentaldb db push. The commands remain reusable in host CLIs:createDbCommand()mounts them as a nesteddbgroup, and the newregisterDbCommands(program)registers them flat on any Commander command. -
Wrangler patching is opt-in: the plugin no longer writes to
wrangler.jsoncby default. It verifies the config and logs the exact JSON to add when Durable Object bindings or sqlite migration entries are missing; passdurableDb({ patchWranglerConfig: true })to restore automatic patching.
The package also moved and got renamed surfaces:
- Published to npm as
durable-db(previously@eagerpatch/durable-dbon GitHub Packages). All import specifiers drop the scope:durable-db,durable-db/vite,durable-db/schema, …. - Plugin renamed:
import { durableDb } from 'durable-db/vite'(thedatabasePluginname remains as a deprecated alias). - Virtual modules renamed:
virtual:durable-db/__durableObjectsandvirtual:durable-db/__devEpoch(the oldvirtual:eagerpatch/…ids still resolve). - Root exports:
defineDatabase,setTenantIdResolver,getTenantId, and the schema builders are importable straight fromdurable-db; the/db,/context, and/schemasubpaths still work. - The dev cache moved to
node_modules/.cache/durable-db(the old@eagerpatchcache is simply abandoned — rundb pushonce after upgrading).
Note: in development, DO instance keys are now suffixed with
__dev_<epoch>; production keys are unchanged.getInstanceKey/getDevInstanceKeySuffixfrom./contextare deprecated in favor of the virtual module. -