Wrap migration ROLLBACK in try/catch to preserve original error

Match the pattern used in StateDb.transaction: if ROLLBACK itself
throws (e.g. bad DB connection state), the original migration error
is still re-thrown instead of being replaced by the rollback error.
This commit is contained in:
Cursor Agent committed 2026-02-20 09:10:36 +00:00
1 parent 05aa27a0d9
commit aac6796d8c
1 file changed
+5 -1
+5 -1
View File
@@ -90,7 +90,11 @@ export function runStateMigrations(db: SqliteDatabase): void {
db.exec(`PRAGMA user_version=${STATE_DB_SCHEMA_VERSION};`);
db.exec("COMMIT;");
} catch (error) {
db.exec("ROLLBACK;");
try {
db.exec("ROLLBACK;");
} catch {
// Preserve the original migration error if rollback also throws.
}
throw error;
}
}