Skip to content

SQLite DDL migration runner (pre-launch requirement) #1320

Closed

Description

@malibio

Before shipping to real users, NodeSpace needs a versioned DDL migration runner so schema changes can be applied to existing databases without data loss.

Problem

`initialize_schema` currently runs `CREATE TABLE IF NOT EXISTS` — idempotent for fresh databases, but silent no-op for existing ones. Any new top-level column added to `node`, `relationship`, or `embedding` will be missing from databases created before that change.

Required Behavior

On startup, `initialize_schema` should:

  1. Read `PRAGMA user_version`
  2. Compare against the app's expected schema version constant
  3. Execute any pending migrations in order (e.g. `ALTER TABLE node ADD COLUMN ...`)
  4. Bump `user_version` to match

Migration File Convention

Each migration is a numbered SQL file or inline Rust constant:

  • `001_initial_schema` — current schema.sql contents, baseline
  • `002_add_node_subtitle` — example future migration
  • Never edit a past migration, only append new ones

`schema.sql` either becomes a human-readable reference (not executed directly) or is removed in favor of deriving current schema from running all migrations on a fresh DB.

Acceptance Criteria

  • `PRAGMA user_version` is used to track applied migration version
  • Current schema is canonicalized as migration `001`
  • New DDL changes are added as numbered migrations, not edits to `schema.sql`
  • A user on migration `001` who upgrades gets all subsequent migrations applied in order
  • Tests cover: fresh DB, already-current DB, multi-step upgrade path

Activity

  1. malibio commented on Jul 11, 2026

    @malibio
    CollaboratorAuthor

    Frontend: 4019 passed (158 files)

  2. self-assigned this
    on Jul 11, 2026
  3. added a commit that references this issue on Jul 11, 2026
    ccf3098
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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