fix(rb-02): migrations run inside a single transaction
Every multi-statement migration and its matching schema_version insert now execute on the same sqlx Transaction. A failure anywhere — a bad statement, the version insert, or the commit itself — rolls the database back to its previous state, so the next startup replays the migration against a clean schema rather than a half-mutated one. Extracted run_migrations_slice(pool, migrations) as the single apply path. run_migrations delegates to it with MIGRATIONS; the test helper run_migrations_up_to now filters MIGRATIONS by target and delegates to the same code, eliminating the duplicated loop that previously lived in the test module. Regression test multi_statement_migration_rolls_back_on_failure injects a poisoned v9 migration (valid CREATE followed by a bogus function call) and asserts neither the partial schema change nor the schema_version row persists after the failure. SQLite DDL participates in transactions, so this is sufficient. Any future migration that needs an implicitly-committing statement (VACUUM / REINDEX / ATTACH — none today) must be its own non-transactional migration; that's a reviewer responsibility. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -11,12 +11,11 @@ Issues here must land before Kon v0.1 ships. Each is sourced from
|
||||
`docs/code-review-2026-04-22.md`. When `gh` CLI is available, these
|
||||
should be mirrored as real GitHub issues on `jakejars/kon`.
|
||||
|
||||
## CRITICAL (3)
|
||||
## CRITICAL (2 open, 1 resolved)
|
||||
|
||||
| # | File | Area | Fix scope |
|
||||
|---|---|---|---|
|
||||
| RB-01 | [c1-live-session-race.md](c1-live-session-race.md) | `src-tauri/commands/live.rs` | large |
|
||||
| RB-02 | [c3-migrations-atomicity.md](c3-migrations-atomicity.md) | `crates/storage/migrations.rs` | medium |
|
||||
| RB-03 | [c4-transcript-profile-fk.md](c4-transcript-profile-fk.md) | `crates/storage/migrations.rs` + `database.rs` | large |
|
||||
|
||||
## MAJOR (7 open, 2 resolved)
|
||||
@@ -35,6 +34,7 @@ should be mirrored as real GitHub issues on `jakejars/kon`.
|
||||
|
||||
| # | File | Area | Resolution |
|
||||
|---|---|---|---|
|
||||
| RB-02 | [c3-migrations-atomicity.md](c3-migrations-atomicity.md) | `crates/storage/migrations.rs` | Each migration now runs inside a `pool.begin()` / `tx.commit()` transaction alongside its `schema_version` insert. Regression test injects a poisoned v9 migration and asserts neither the partial schema change nor the version row persists. DRY'd `run_migrations_up_to` test helper onto the same code path. |
|
||||
| RB-09 | [decoder-partial-audio-on-error.md](decoder-partial-audio-on-error.md) | `crates/audio/decode.rs` | Packet-loop now propagates all non-EOF `SymphoniaError`s as `AudioDecodeFailed`; per-packet decode errors bubble via `?`. Mock-`MediaSource` regression test confirms mid-stream I/O errors surface instead of returning partial audio. |
|
||||
| RB-12 | [hotkey-linux-device-filter.md](hotkey-linux-device-filter.md) | `crates/hotkey/linux.rs` | Extracted `device_supports_combo` helper; `try_attach_device` now reads the configured `HotkeyCombo` from the watch channel and checks support for that trigger key. Four regression tests land in `linux::tests`. |
|
||||
|
||||
|
||||
Reference in New Issue
Block a user