Skip to content

Fix: project_insight_runs table missing lifecycle column #41

@timothyjlaurent

Description

@timothyjlaurent

Bug

Clicking "Generate Insights" produces the error:

table project_insight_runs has no column named lifecycle

Root Cause

The lifecycle and cancelledAt columns were added to project_insight_runs in a commit that updated both SCHEMA_SQL (for fresh DBs) and retroactively inserted them into migration v33's CREATE TABLE. A safety-net addColumnIfMissing was placed inside the version < 59 migration block.

However, databases that were already at schema version 59+ when that commit landed never re-run v59. The SCHEMA_SQL uses CREATE TABLE IF NOT EXISTS, which is a no-op when the table already exists. Result: the columns are missing.

The codebase already has a pattern for exactly this scenario — ensureRoutinesSchemaCompatibility() runs unconditionally on every init(), outside the version-gated migration path.

Fix

Add ensureInsightRunsSchemaCompatibility() following the same pattern — idempotent addColumnIfMissing calls that run on every database initialization.

Reproduction

  1. Use a database that was created before the lifecycle columns were added
  2. Run migrations to current schema version
  3. Click "Generate Insights" in the dashboard
  4. Observe the SQLite error about missing lifecycle column

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions