Skip to content

Agent DB schema migrations #33

Description

@RatulMaharaj

The agent's SQLite store (packages/core/store/store.ts) creates its tables with CREATE TABLE IF NOT EXISTS and has no versioning. That works until a release changes a table's shape: an existing data volume then has the old columns, IF NOT EXISTS skips it and the runtime hits missing-column errors at runtime rather than at startup.

Add a migration mechanism so schema changes are safe across upgrades of long-lived agents:

  • Track a schema version (PRAGMA user_version is the natural fit)
  • On startup, run ordered migrations from the stored version to the current one, inside a transaction
  • Fail loudly at startup if the database is newer than the runtime (downgrade case)
  • A fresh database just gets the latest schema and version

This matters because the data volume is the agent's identity and history; "wipe /data" can't be the upgrade story once agents run unattended for months.

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions