Context
Restore feature — backup/restore feature (DESIGN_REQUIREMENTS FR-8). Per docs/audits/backup.md F3.
Problem
src/components/backup/RestoreDialog.tsx reads SQL file, splits via splitSqlStatements, runs each via api.executeQuery. Grep for BEGIN|COMMIT|ROLLBACK|FOREIGN_KEY_CHECKS in RestoreDialog returns zero hits. No START TRANSACTION wrapper, no SET FOREIGN_KEY_CHECKS=0. A dump with CREATE TABLE users (...) followed by INSERT INTO users VALUES (...) where INSERT fails leaves the DB with the new (empty) table but not the inserts — silent data loss.
Files
- src/components/backup/RestoreDialog.tsx:65-385
Repro
- Create test dump with intentional column-count mismatch mid-file
- Restore against empty DB with stopOnError=true
- Observe first N-1 statements committed, dump aborted mid-way
Expected
Whole restore wrapped in transaction. On error, full rollback (when stopOnError=true).
Proposed fix
M: wrap whole restore in BEGIN...COMMIT/ROLLBACK block. Add SET FOREIGN_KEY_CHECKS=0/=1 prologue/epilogue. Surface partial-restore status explicitly.
Acceptance
Dump with one mid-file error restored against empty DB with stopOnError=true results in zero tables created (full rollback).
Needs human verify
yes
Context
Restore feature — backup/restore feature (DESIGN_REQUIREMENTS FR-8). Per docs/audits/backup.md F3.
Problem
src/components/backup/RestoreDialog.tsx reads SQL file, splits via splitSqlStatements, runs each via api.executeQuery. Grep for BEGIN|COMMIT|ROLLBACK|FOREIGN_KEY_CHECKS in RestoreDialog returns zero hits. No START TRANSACTION wrapper, no SET FOREIGN_KEY_CHECKS=0. A dump with CREATE TABLE users (...) followed by INSERT INTO users VALUES (...) where INSERT fails leaves the DB with the new (empty) table but not the inserts — silent data loss.
Files
Repro
Expected
Whole restore wrapped in transaction. On error, full rollback (when stopOnError=true).
Proposed fix
M: wrap whole restore in BEGIN...COMMIT/ROLLBACK block. Add SET FOREIGN_KEY_CHECKS=0/=1 prologue/epilogue. Surface partial-restore status explicitly.
Acceptance
Dump with one mid-file error restored against empty DB with stopOnError=true results in zero tables created (full rollback).
Needs human verify
yes