From fb84b5a5549a6ffb6e0811f61f9c11b8e01292df Mon Sep 17 00:00:00 2001 From: MayaTheShy Date: Fri, 20 Feb 2026 04:19:03 -0500 Subject: [PATCH] refactor: add name and color columns to mining_areas table and handle migration --- server/database.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/server/database.js b/server/database.js index ae064bc..d63ddb0 100644 --- a/server/database.js +++ b/server/database.js @@ -85,12 +85,28 @@ export function initializeDatabase() { max_x INTEGER NOT NULL, max_y INTEGER NOT NULL, max_z INTEGER NOT NULL, + name TEXT, + color TEXT DEFAULT '#4a8c2a', status TEXT DEFAULT 'active', created_at INTEGER NOT NULL, updated_at INTEGER NOT NULL ) `); + // Migrate existing mining_areas table to add name/color columns if missing + try { + const tableInfo = db.prepare("PRAGMA table_info(mining_areas)").all(); + const columns = tableInfo.map(c => c.name); + if (!columns.includes('name')) { + db.exec('ALTER TABLE mining_areas ADD COLUMN name TEXT'); + } + if (!columns.includes('color')) { + db.exec("ALTER TABLE mining_areas ADD COLUMN color TEXT DEFAULT '#4a8c2a'"); + } + } catch (e) { + // Ignore migration errors + } + // Mining statistics table db.exec(` CREATE TABLE IF NOT EXISTS mining_stats (