run_object_schema

Function run_object_schema 

Source
pub fn run_object_schema(conn: &Connection) -> Result<(), StoreError>
Expand description

Initialize (or re-validate) the full objects.db schema.

Idempotent — safe on every srv startup. Steps:

  1. adopt_legacy_table_names — renames any pre-flatten forge/bundle tables found (protects dev databases created before the flatten; see the spec §3/§7) and drops the dead workflow/sentinel tables.
  2. The flat CREATE TABLE IF NOT EXISTS batch — the canonical schema.
  3. Seeds the blank Identity / Memory singleton rows.

A database stuck at a pre-v11 intermediate schema cannot be fully adopted (its tables predate later columns). The adopt step still renames what it finds; the first query referencing a missing column then fails loudly with no such column — a hard error, not silent empty state, with the data preserved on disk. Per-version data dirs make that case unreachable for released builds.