Restore drills are part of our checks now
A backup you have never restored is a file, not a backup. Steward rehearses the restore now: replay an older dump into a current database, bring the workspace up, assert it comes back clean. It runs as part of the checks, so it happens on every change rather than on the day somebody needs it.
Writing that drill is what this post is about, because the first run of it earned its keep three times over.
Why it took until November
Every customer in Steward has their own database with its own migration history, and our conventions have said in bold for over a year that migrations must be safely replayable. We believed that. We had written it down, which is a different thing from having checked it.
We’d even hit the edge of it in July, when we bricked a test tenant restoring its own backup, patched the specific error it threw and moved on without writing the test. That was the mistake. One symptom got fixed and the class of problem stayed open for four more months.
What the first drill found
Three defects, each of which would have broken recovery for a real customer.
Foreign keys were being enforced and we’d assumed they weren’t. The restore cleared the existing tables in the order the migrations created them, parents first, which is fine if the schema’s twelve REFERENCES clauses are documentation. In Durable Object SQLite they are enforced by default. So clearing the accounts table while revenue events still pointed at it aborted the restore on a constraint failure, for any workspace with enough data to have relationships in it. An empty test workspace restored perfectly, which is exactly why this survived.
Older dumps wouldn’t initialise. Our early migrations create tables without “if not exists” — We only started writing it that way at version 24. Restoring an older dump threw from inside the constructor, so the workspace didn’t fail to restore, it failed to come up at all.
Replays could skip backfills. Each schema version ran as one statement batch in one transaction, so on a replay the first already-applied column threw and took the rest of that version with it, backfills included. A replay could finish looking correct while silently leaving data unpopulated. That’s the one we’d least want to discover from a customer: no error, right-looking schema, missing values.
All three are fixed, with per-statement isolation on replay so one already-applied change can’t cancel the work behind it. And the drill that found them now runs against every change, which is the part that actually matters — a fix without a test is a fix with a shelf life.
The general version
None of this is really about SQLite. It’s that a documented invariant with no test behind it is a belief, and writing it down in bold made it feel examined when it wasn’t.
If you run anything with a recovery path, the useful question isn’t whether you have backups. It’s when you last restored one into a system that had moved on since, and whether anything would tell you if that stopped working.
The rest of the month
Writes from eighteen different hooks weren’t refreshing the views they should have after the first page of results loaded, so you’d add something and the list would keep showing the old state until you reloaded. Every write landed — nothing was lost — but a UI that doesn’t reflect a successful write trains people not to trust it, and then they do everything twice. Four fixes across the timeline, audit log, accounts list and tasks.
The app also got an error boundary, which it didn’t have before, so an unhandled render error no longer takes out the whole page. And a central retry policy, so a 400 doesn’t get retried four times on its way to telling you what you typed wrong.
On capacity: a database per customer has a ceiling, 10 GB per workspace, which we had never actually measured against real usage. There’s a nightly job measuring it now with a warning threshold at 2 GB, plus retention on the two tables that otherwise grow forever — the audit log at 400 days, notifications at 90.
Toolchain moved too: React Router 7, Vite 8, Vitest 5, with the vendor bundle split in two to stay inside its 300 kB budget.
— Bruno