Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

All notable changes to Claude Matrix are documented here.

## [2.1.4] - 2025-01-18

### Fixed

#### Database Initialization
- **Missing `plugin_meta` Table** - Fixed session start crash when inserting plugin metadata
- `session-start.ts` attempted to INSERT into `plugin_meta` table that didn't exist
- Added `plugin_meta` table to `schema.ts` for fresh installs
- Added v6 migration in `migrate.ts` for existing databases
- Added v6 version detection in migration logic

### Database Schema

- **v6 Migration** - Added plugin metadata table
- `plugin_meta`: Key-value store for plugin version, install source, etc.

---

## [2.1.3] - 2025-01-18

### Changed
Expand Down
26 changes: 24 additions & 2 deletions src/db/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { homedir } from 'os';
import { SCHEMA_SQL } from './schema.js';

// Schema version - increment when schema changes
const SCHEMA_VERSION = 5;
const SCHEMA_VERSION = 6;

// Migration definitions - each migration upgrades from (version - 1) to version
const migrations: Record<number, string> = {
Expand Down Expand Up @@ -133,6 +133,15 @@ const migrations: Record<number, string> = {
CREATE INDEX IF NOT EXISTS idx_dreamer_executions_started ON dreamer_executions(started_at DESC);
CREATE INDEX IF NOT EXISTS idx_dreamer_executions_status ON dreamer_executions(status);
`,

// v5 -> v6: Plugin metadata table
6: `
CREATE TABLE IF NOT EXISTS plugin_meta (
key TEXT PRIMARY KEY,
value TEXT NOT NULL,
updated_at TEXT DEFAULT (datetime('now'))
);
`,
};

function getDbPath(): string {
Expand Down Expand Up @@ -208,7 +217,20 @@ function getCurrentVersion(db: Database): number {
}
}

const initialVersion = hasV5Tables ? 5 : (hasV4Columns ? 4 : (hasV3Columns ? 3 : (hasAllV2Tables ? 2 : 1)));
// Check for v6 (plugin_meta table)
let hasV6Tables = false;
if (hasV5Tables) {
try {
const pluginMetaTable = db.query(`
SELECT name FROM sqlite_master WHERE type='table' AND name='plugin_meta'
`).get();
hasV6Tables = !!pluginMetaTable;
} catch {
hasV6Tables = false;
}
}

const initialVersion = hasV6Tables ? 6 : (hasV5Tables ? 5 : (hasV4Columns ? 4 : (hasV3Columns ? 3 : (hasAllV2Tables ? 2 : 1))));
db.exec(`INSERT INTO schema_version (version) VALUES (${initialVersion})`);
return initialVersion;
} else {
Expand Down
7 changes: 7 additions & 0 deletions src/db/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ CREATE TABLE IF NOT EXISTS hook_executions (
PRIMARY KEY (hook_name, session_id)
);

-- Plugin metadata (version, install source, etc.)
CREATE TABLE IF NOT EXISTS plugin_meta (
key TEXT PRIMARY KEY,
value TEXT NOT NULL,
updated_at TEXT DEFAULT (datetime('now'))
);

-- Background job tracking for async operations
CREATE TABLE IF NOT EXISTS background_jobs (
id TEXT PRIMARY KEY,
Expand Down
Loading