fix(db): keep reviewed_real out of the Migration-1 rebuild table (positional SELECT *); regression test

This commit is contained in:
2026-08-25 00:31:39 +00:00
parent d9cc5f1780
commit 23e4f585a8
3 changed files with 45 additions and 2 deletions
@@ -47,8 +47,8 @@ def test_existing_db_migrates_reviewed_real(tmp_path):
- [ ] **Step 2: Run → FAIL** (`pytest tests/test_reviewed_real_column.py -q`).
- [ ] **Step 3: Implement**
- In `_SCHEMA` `events` CREATE TABLE, after the `false_trigger ... DEFAULT 0,` line add: ` reviewed_real INTEGER NOT NULL DEFAULT 0, -- 0=no, 1=operator-confirmed real (mutually exclusive with false_trigger)`
- In the Migration-1 rebuild `CREATE TABLE events (...)` block, add the same `reviewed_real INTEGER NOT NULL DEFAULT 0,` line after `false_trigger`.
- In the `_migrate` ADD COLUMN loop tuple add: `("reviewed_real", "INTEGER NOT NULL DEFAULT 0"),`
- **Do NOT** add it to the Migration-1 rebuild `CREATE TABLE events (...)` block — that block uses a positional `INSERT ... SELECT * FROM events_old` and, by convention, contains only the columns that existed when Migration 1 was written; every later column is added by the ADD COLUMN loop only. Adding it there crashes `_migrate` on genuinely legacy (pre-Migration-1) DBs.
- [ ] **Step 4: Run → PASS.**
- [ ] **Step 5: Commit** `feat(db): reviewed_real column on events (+ auto-migrate)`