diff --git a/DEVELOPMENT_LOG.md b/DEVELOPMENT_LOG.md index 1805c78..8565eed 100644 --- a/DEVELOPMENT_LOG.md +++ b/DEVELOPMENT_LOG.md @@ -6,6 +6,36 @@ --- +### v0.20.3 — Missing Database Indexes +**Status:** ✅ COMPLETED +**Date:** 2026-05-10 +**Priority:** HIGH + +| Agent | Status | Time | Notes | +|-------|--------|------|-------| +| Neo | ✅ COMPLETED | 2m40s | Added v0.44 migration with 4 indexes | +| Bishop | ✅ COMPLETED | 2m33s | Docker build, all indexes verified, version bumped | +| Hudson | ⏳ PENDING | — | Security audit | +| Ripley | 🔄 IN PROGRESS | — | Fixed nested transaction bug, awaiting Hudson | + +**Files modified:** `db/database.js`, `client/lib/version.js`, `package.json` + +**Task ID:** missing-indexes-003 + +**Objective:** +Add performance indexes on frequently queried columns to eliminate full table scans. + +**Work Completed:** +- [x] Added v0.44 migration with 4 CREATE INDEX statements +- [x] Fixed nested transaction bug (migration run() should NOT have its own BEGIN/COMMIT) +- [x] All indexes use IF NOT EXISTS for idempotency +- [x] Docker build passes, login works, no errors +- [x] Version bumped to 0.20.3 + +**Security Audit (Hudson):** Pending + +--- + ### v0.20.2 — Transaction Wrapping for Migrations **Status:** ✅ COMPLETED **Date:** 2026-05-10 diff --git a/FUTURE.md b/FUTURE.md index 9b44daf..4042d61 100644 --- a/FUTURE.md +++ b/FUTURE.md @@ -59,31 +59,7 @@ Migrations have implicit dependencies (e.g., adding columns to tables that must - Enforce topological sort order - Test dependency failures to ensure proper error messages -### Database Query Optimization: Add Missing Indexes -**Priority:** HIGH -**Added:** 2026-05-08 by Neo - -**Description:** -Several frequently queried columns lack indexes, causing full table scans on growth. - -**Rationale:** -- `bills.name` and `bills.user_id` are used in WHERE clauses but only indexed as part of composite indexes -- `payments.method` is used for filtering but has no index -- `monthly_starting_amounts.user_id` exists but lacks explicit index -- `import_history.imported_at` is used for cleanup but not indexed - -**Implementation Notes:** -- Files to modify: `/home/kaspa/.openclaw/Projects/bill-tracker/db/database.js` (migrations section) -- Estimated effort: 30 minutes -- Add these indexes: - ```sql - CREATE INDEX IF NOT EXISTS idx_bills_user_name ON bills(user_id, name); - CREATE INDEX IF NOT EXISTS idx_payments_method ON payments(method); - CREATE INDEX IF NOT EXISTS idx_monthly_starting_amounts_user ON monthly_starting_amounts(user_id); - CREATE INDEX IF NOT EXISTS idx_import_history_imported_at ON import_history(imported_at); - ``` - -### Security: Missing Input Validation on Bulk Operations + Missing Input Validation on Bulk Operations **Priority:** HIGH **Added:** 2026-05-08 by Neo diff --git a/HISTORY.md b/HISTORY.md index 226fce0..b32a6bf 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,14 @@ # Bill Tracker — Changelog +## v0.20.3 + +### Added +- **Database performance indexes** — v0.44 migration adds 4 indexes on frequently queried columns: + - `idx_bills_user_name` on `bills(user_id, name)` — user-scoped bill lookups + - `idx_payments_method` on `payments(method)` — payment method filtering + - `idx_monthly_starting_amounts_user` on `monthly_starting_amounts(user_id)` — user starting amounts + - `idx_import_history_imported_at` on `import_history(imported_at)` — time-based import queries + ## v0.20.2 ### Added diff --git a/client/lib/version.js b/client/lib/version.js index 96047fc..cef3497 100644 --- a/client/lib/version.js +++ b/client/lib/version.js @@ -1,10 +1,10 @@ -export const APP_VERSION = '0.20.2'; +export const APP_VERSION = '0.20.3'; export const APP_NAME = 'BillTracker'; export const RELEASE_NOTES = { - version: '0.20.2', + version: '0.20.3', date: '2026-05-09', highlights: [ - { icon: '📦', title: 'Transaction Wrapping', desc: 'All database migrations now run within transactions for data integrity.' }, + { icon: '⚡', title: 'Database Indexes', desc: 'Performance indexes on frequently queried columns.' }, ], }; \ No newline at end of file diff --git a/db/database.js b/db/database.js index b82f761..e9cce7f 100644 --- a/db/database.js +++ b/db/database.js @@ -980,6 +980,17 @@ function runMigrations() { console.log('[migration] sessions.created_at column added'); } } + }, + { + version: 'v0.44', + description: 'performance: add missing indexes for frequently queried columns', + run: function() { + db.exec('CREATE INDEX IF NOT EXISTS idx_bills_user_name ON bills(user_id, name)'); + db.exec('CREATE INDEX IF NOT EXISTS idx_payments_method ON payments(method)'); + db.exec('CREATE INDEX IF NOT EXISTS idx_monthly_starting_amounts_user ON monthly_starting_amounts(user_id)'); + db.exec('CREATE INDEX IF NOT EXISTS idx_import_history_imported_at ON import_history(imported_at)'); + console.log('[migration] Added indexes for frequently queried columns'); + } } ]; diff --git a/package.json b/package.json index e58e857..66d0bfb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bill-tracker", - "version": "0.20.2", + "version": "0.20.3", "description": "Monthly bill tracking system", "main": "server.js", "scripts": {