Skip to content

v3.0: migrate flat-JSON persistence to SQLite behind the Storage interface #531

Description

@hessius

Follow-up from the v3.0.0 unified-core design (deferred decision: ship flat-JSON first, migrate to SQLite later).

Context

v3.0.0 introduces a Platform.Storage/Repo interface (read/list/write/delete) with two backends:

  • browser — IndexedDB (AppDatabase)
  • node/Bun — flat JSON files mapped 1:1 to the existing /data/*.json files (settings, profile_history, scheduled_shots, recurring_schedules, annotations, cache, image dir), atomic temp-file+rename.

Flat JSON was chosen for zero-migration continuity with 2.x server users. SQLite was explicitly deferred to this issue.

Scope

  • Add a SQLite-backed Repo implementation for the node/Bun platform (via bun:sqlite), selected behind the same Storage interface — no core/handler changes.
  • One-time, idempotent migration on first boot: import existing /data/*.json into SQLite, keeping JSON as a backup (rename to *.json.bak), with a rollback path.
  • Keep the browser (IndexedDB) backend as-is; this is server-side only.
  • Preserve exact record shapes and the /api/* contract (validated by the ported core contract-test suite).

Acceptance

  • bun:sqlite Repo passes the same contract tests as the flat-JSON Repo.
  • Boot migration is idempotent and reversible; documented rollback.
  • No change to /api/* responses; full core suite green.

Refs: docs/superpowers/specs/2026-07-02-unified-ts-core-bun-server-3.0.0-design.md, docs/superpowers/plans/2026-07-02-unified-ts-core-bun-server-3.0.0.md (Phase 4 persistence).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions