From c211a41579ff9f4c50e508f6b6db690180fcdd7d Mon Sep 17 00:00:00 2001 From: rUv Date: Tue, 8 Jul 2025 17:12:32 +0000 Subject: [PATCH] fix: resolve hive-mind database optimization errors - Remove DEFAULT CURRENT_TIMESTAMP from ALTER TABLE statements (not supported by SQLite) - Update initial schema to include all required columns (accessed_at, access_count, compressed, size) - Fix second CREATE TABLE statements to include priority, completed_at, and updated_at columns - Ensure both schema creation paths have consistent column definitions - Tested with fresh databases and existing swarms - all working correctly --- src/cli/simple-commands/hive-mind.js | 9 ++++++++- src/cli/simple-commands/hive-mind/db-optimizer.js | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/cli/simple-commands/hive-mind.js b/src/cli/simple-commands/hive-mind.js index 12ed7c354a..1a9536bf21 100644 --- a/src/cli/simple-commands/hive-mind.js +++ b/src/cli/simple-commands/hive-mind.js @@ -157,6 +157,10 @@ async function initHiveMind(flags) { confidence REAL DEFAULT 1.0, created_by TEXT, created_at DATETIME DEFAULT CURRENT_TIMESTAMP, + accessed_at DATETIME, + access_count INTEGER DEFAULT 0, + compressed INTEGER DEFAULT 0, + size INTEGER DEFAULT 0, FOREIGN KEY (swarm_id) REFERENCES swarms(id) ); @@ -427,7 +431,8 @@ async function spawnSwarm(args, flags) { objective TEXT, queen_type TEXT, status TEXT DEFAULT 'active', - created_at DATETIME DEFAULT CURRENT_TIMESTAMP + created_at DATETIME DEFAULT CURRENT_TIMESTAMP, + updated_at DATETIME ); CREATE TABLE IF NOT EXISTS agents ( @@ -448,8 +453,10 @@ async function spawnSwarm(args, flags) { agent_id TEXT, description TEXT, status TEXT DEFAULT 'pending', + priority INTEGER DEFAULT 5, result TEXT, created_at DATETIME DEFAULT CURRENT_TIMESTAMP, + completed_at DATETIME, FOREIGN KEY (swarm_id) REFERENCES swarms(id), FOREIGN KEY (agent_id) REFERENCES agents(id) ); diff --git a/src/cli/simple-commands/hive-mind/db-optimizer.js b/src/cli/simple-commands/hive-mind/db-optimizer.js index 82984c46dd..c005bc3028 100644 --- a/src/cli/simple-commands/hive-mind/db-optimizer.js +++ b/src/cli/simple-commands/hive-mind/db-optimizer.js @@ -260,7 +260,7 @@ function ensureRequiredColumns(db) { if (!hasUpdatedAt || hasUpdatedAt.count === 0) { try { - db.exec('ALTER TABLE swarms ADD COLUMN updated_at DATETIME DEFAULT CURRENT_TIMESTAMP'); + db.exec('ALTER TABLE swarms ADD COLUMN updated_at DATETIME'); console.log('Added missing updated_at column to swarms table'); } catch (error) { if (!error.message.includes('duplicate column')) { @@ -374,7 +374,7 @@ function addMemoryOptimization(db) { try { db.exec(` ALTER TABLE collective_memory - ADD COLUMN accessed_at DATETIME DEFAULT CURRENT_TIMESTAMP + ADD COLUMN accessed_at DATETIME `); console.log('Added accessed_at column to collective_memory table'); } catch (error) {