Skip to content

Initialize database schema (Pure JSON, no migrations) #102

Closed

Description

@malibio

Overview

Initialize database schema with Pure JSON architecture - single nodes table with no complementary tables and no ALTER TABLE migrations.

Implementation Tasks

  • Create initial database initialization (CREATE TABLE IF NOT EXISTS)
  • Implement nodes table with Pure JSON properties field
  • Add node_mentions relation table
  • Create core indexes (node_type, parent_id, root_id, modified_at)
  • Seed core schemas (task, person, date, project, text) as nodes
  • Add IndexManager for dynamic JSON path indexes

Acceptance Criteria

  • Database initialization creates nodes table (no migrations, no ALTER TABLE)
  • nodes table has Pure JSON properties field (ALL entity data here)
  • node_mentions table for bidirectional reference queries
  • Core indexes created (never change)
  • Core schemas seeded as nodes with node_type = 'schema'
  • IndexManager ready for dynamic JSON path index creation
  • No complementary tables (tasks, persons, etc.)
  • Zero migration risk for desktop deployments

Technical Specifications

Schema Structure:

CREATE TABLE IF NOT EXISTS nodes (
    id TEXT PRIMARY KEY,
    node_type TEXT NOT NULL,
    content TEXT NOT NULL,
    parent_id TEXT,
    root_id TEXT,
    before_sibling_id TEXT,
    created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
    modified_at DATETIME DEFAULT CURRENT_TIMESTAMP,
    properties JSON NOT NULL DEFAULT '{}',
    embedding_vector BLOB,
    FOREIGN KEY (parent_id) REFERENCES nodes(id) ON DELETE CASCADE,
    FOREIGN KEY (root_id) REFERENCES nodes(id)
);

CREATE TABLE IF NOT EXISTS node_mentions (
    node_id TEXT NOT NULL,
    mentions_node_id TEXT NOT NULL,
    PRIMARY KEY (node_id, mentions_node_id),
    FOREIGN KEY (node_id) REFERENCES nodes(id) ON DELETE CASCADE,
    FOREIGN KEY (mentions_node_id) REFERENCES nodes(id) ON DELETE CASCADE
);

Core Schemas to Seed:

  • task, person, date, project, text (as schema nodes)

Key Principle:

  • NO migrations after initial setup
  • NO ALTER TABLE ever (desktop constraint)
  • Dynamic JSON path indexes only

This establishes Pure JSON schema foundation with zero migration risk.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions