From 196caca42a4d940b0ec40e2f4b79033756cc8565 Mon Sep 17 00:00:00 2001 From: minibits-cash Date: Thu, 4 Jun 2026 15:17:50 +0200 Subject: [PATCH] fix(db): drop mint_counters + reservations in cleanAll cleanAll only dropped transactions/proofs/dbversion, leaving the mint_counters and reservations tables (added by later migrations) behind. A wallet wipe would keep stale derivation counters, which the next launch would hydrate. Drop them too (IF EXISTS, so an old DB lacking them doesn't abort the atomic batch). Tables are recreated on next launch via the IF-NOT-EXISTS schema bootstrap. Co-Authored-By: Claude Opus 4.8 --- src/services/db/instance.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/services/db/instance.ts b/src/services/db/instance.ts index 105a47e1..49dd823b 100644 --- a/src/services/db/instance.ts +++ b/src/services/db/instance.ts @@ -59,6 +59,10 @@ export const cleanAll = function () { ['DROP TABLE transactions'], ['DROP TABLE proofs'], ['DROP TABLE dbversion'], + // IF EXISTS: these tables were added by later migrations, so a very old DB + // may lack them; without the guard a missing table aborts the atomic batch. + ['DROP TABLE IF EXISTS reservations'], + ['DROP TABLE IF EXISTS mint_counters'], ] as SQLBatchTuple[] try {