From e9378f2176cbcde3b25d7e042ee9b3a057bfa3a3 Mon Sep 17 00:00:00 2001 From: LemonNexus Date: Wed, 11 Feb 2026 10:35:36 +0000 Subject: [PATCH] fix: add description column to projects table with migration - Add description column to projects table in schema.sql - Add _run_migrations() method to handle schema updates - Migration automatically adds description column to existing databases --- core/database.py | 20 ++++++++++++++++++++ core/schema.sql | 1 + 2 files changed, 21 insertions(+) diff --git a/core/database.py b/core/database.py index 8e33463..714045e 100644 --- a/core/database.py +++ b/core/database.py @@ -64,6 +64,9 @@ class DatabaseManager: conn.executescript(schema) conn.commit() + # Run migrations for existing databases + self._run_migrations() + logger.info("Database schema initialized successfully") return True @@ -71,6 +74,23 @@ class DatabaseManager: logger.error(f"Failed to initialize database: {e}") return False + def _run_migrations(self): + """Run migrations to update existing databases.""" + try: + conn = self.get_connection() + + # Migration: Add description column to projects table + try: + conn.execute("ALTER TABLE projects ADD COLUMN description TEXT") + conn.commit() + logger.info("Migration: Added description column to projects table") + except sqlite3.OperationalError: + # Column already exists + pass + + except Exception as e: + logger.error(f"Migration failed: {e}") + def get_connection(self) -> sqlite3.Connection: """ Get or create database connection. diff --git a/core/schema.sql b/core/schema.sql index d6ee0c7..00add92 100644 --- a/core/schema.sql +++ b/core/schema.sql @@ -14,6 +14,7 @@ PRAGMA foreign_keys = ON; CREATE TABLE IF NOT EXISTS projects ( id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, + description TEXT, type TEXT NOT NULL CHECK (type IN ('hunt', 'mine', 'craft', 'inventory')), status TEXT NOT NULL DEFAULT 'active' CHECK (status IN ('active', 'paused', 'completed', 'archived')), created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,