Skip to content

fix: backup/reimport drops raw_id column causing NULL scan errors #334

@CalebisGross

Description

@CalebisGross

Context

During a DB nuke and reimport (2026-03-21), the reimport script did not populate the raw_id column on memories. This caused recall_project to crash with:

sql: Scan error on column index 1, name "raw_id": converting NULL to string is unsupported

122 out of 124 reimported memories had NULL raw_id. Fixed manually with UPDATE memories SET raw_id = id WHERE raw_id IS NULL.

Root cause

The export/reimport SQL didn't include raw_id in the INSERT statement. The column has no DEFAULT and no NOT NULL constraint, so SQLite silently accepted NULLs.

Fix

  • Ensure backup export includes raw_id in the column list
  • Ensure reimport populates raw_id (use id as fallback if not present in source data)
  • Consider adding NOT NULL DEFAULT '' or a CHECK constraint to prevent silent NULLs in the future
  • Add a post-reimport validation step that checks for NULL required fields

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