Repository navigation
Description
Bug: v0.5.0 schema migration fails upgrading from v0.4.x — no such column: path
Description
When upgrading uteke from v0.4.3 to v0.5.0, the automatic schema migration fails because it tries to CREATE INDEX on new documents table columns (path, parent_id, depth, sort_order) before those columns exist. This breaks all uteke commands (doctor, stats, recall, export, etc.) since the migration runs at startup.
Steps to Reproduce
- Have a working v0.4.3 install with an existing DB (
~/.uteke/uteke.db) that has adocumentstable created by v0.4.x - Upgrade binary to v0.5.0:
curl -fsSL -o uteke.tar.gz https://github.com/codecoradev/uteke/releases/download/v0.5.0/uteke-aarch64-apple-darwin-v0.5.0.tar.gz tar xzf uteke.tar.gz cp uteke ~/.local/bin/uteke cp uteke-serve ~/.local/bin/uteke-serve
- Run any uteke command:
uteke doctor
Expected Behavior
Schema migration adds the new columns, creates indexes, and completes successfully.
Actual Behavior
Migration fails with:
2026-06-29T14:18:00.937145Z WARN uteke_core::error: database error context="database operation" err=no such column: path in
CREATE INDEX IF NOT EXISTS idx_documents_path ON documents(path);
CREATE INDEX IF NOT EXISTS idx_documents_parent ON documents(parent_id);
CREATE INDEX IF NOT EXISTS idx_documents_depth ON documents(depth);
CREATE INDEX IF NOT EXISTS idx_documents_sort ON documents(parent_id, sort_order);
The v0.4.x documents table schema:
CREATE TABLE documents (
id TEXT PRIMARY KEY,
slug TEXT NOT NULL COLLATE NOCASE,
title TEXT NOT NULL,
content TEXT NOT NULL,
namespace TEXT NOT NULL DEFAULT "default",
tags TEXT DEFAULT "[]",
metadata TEXT DEFAULT "{}",
version INTEGER NOT NULL DEFAULT 1,
content_type TEXT NOT NULL DEFAULT "markdown",
created_at TEXT NOT NULL,
updated_at TEXT NOT NULL,
UNIQUE(namespace, slug)
);The v0.5.0 migration tries to CREATE INDEX on path, parent_id, depth, sort_order — columns that don't exist in the old table. The ALTER TABLE ADD COLUMN steps that should run before the index creation appear to be missing or misordered.
Impact: This is a total blocker — every command fails because the migration runs unconditionally at startup. Even uteke export (the natural recovery path) is broken. Rolling back to the v0.4.3 binary doesn't help either if the DB has been partially touched.
Workaround
Manually add the missing columns before running v0.5.0:
sqlite3 ~/.uteke/uteke.db "
ALTER TABLE documents ADD COLUMN path TEXT;
ALTER TABLE documents ADD COLUMN parent_id TEXT;
ALTER TABLE documents ADD COLUMN depth INTEGER NOT NULL DEFAULT 0;
ALTER TABLE documents ADD COLUMN sort_order INTEGER NOT NULL DEFAULT 0;
"
uteke doctor # now completes schema migration v12 and succeedsAfter this manual fix, uteke doctor reports:
✓ SQLite DB: 261 memories, 2.5 MB
✓ usearch index: 261 vectors
✓ Index consistency: DB=261 Index=261
✓ All checks passed.
Root Cause (likely)
The migration for the documents table hierarchy feature (#406/#411) adds new columns. The ALTER TABLE ADD COLUMN statements must execute before the CREATE INDEX statements that reference those columns. The migration runner appears to execute the index DDL before the column DDL, or the ALTER TABLE statements are missing from the migration entirely.
Environment
- OS: macOS 15.5 (Apple Silicon, aarch64-apple-darwin)
- uteke version: 0.4.3 → 0.5.0
- schema_version in DB: 11 (before upgrade)
- Documents table: present (from v0.4.x), 0 rows
- Memories: 261 in namespace
hermes
Suggested Fix
Ensure the migration script adds columns before creating indexes:
-- Step 1: Add columns (idempotent check needed)
ALTER TABLE documents ADD COLUMN path TEXT;
ALTER TABLE documents ADD COLUMN parent_id TEXT;
ALTER TABLE documents ADD COLUMN depth INTEGER NOT NULL DEFAULT 0;
ALTER TABLE documents ADD COLUMN sort_order INTEGER NOT NULL DEFAULT 0;
-- Step 2: Create indexes (only after columns exist)
CREATE INDEX IF NOT EXISTS idx_documents_path ON documents(path);
CREATE INDEX IF NOT EXISTS idx_documents_parent ON documents(parent_id);
CREATE INDEX IF NOT EXISTS idx_documents_depth ON documents(depth);
CREATE INDEX IF NOT EXISTS idx_documents_sort ON documents(parent_id, sort_order);Alternatively, wrap column additions in a check (SQLite doesn't support IF NOT EXISTS on ADD COLUMN, so guard with a PRAGMA check or try/catch).
Activity
Merge pull request #493 from codecoradev/fix/schema-migration-v12-ind…
fix: remove duplicate document indexes from SCHEMA constant (fixes co…
release: v0.6.0 — batch import, embed fallback, bug fixes
fix: remove duplicate document indexes from SCHEMA constant (fixes #492)
Merge pull request #493 from codecoradev/fix/schema-migration-v12-ind…
release: v0.6.0 — batch import, embed fallback, bug fixes