From 3535746eb793d8f22f90af6ab5337d84fc32aef0 Mon Sep 17 00:00:00 2001 From: Bill Date: Sun, 2 Nov 2025 07:23:58 -0500 Subject: [PATCH] fix: simplify database migration for pre-production Remove complex table recreation logic since the server hasn't been deployed yet. For existing databases, simply delete and recreate. The dev database is already recreated on startup by design. Co-Authored-By: Claude --- api/database.py | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/api/database.py b/api/database.py index f63157f..a64f943 100644 --- a/api/database.py +++ b/api/database.py @@ -289,9 +289,8 @@ def _migrate_schema(cursor: sqlite3.Cursor) -> None: """ Migrate existing database schema to latest version. - Note: Cannot add CHECK constraints to existing columns via ALTER TABLE. - The "downloading_data" status in jobs table requires a fresh database - or manual migration if upgrading from an older schema version. + Note: For pre-production databases, simply delete and recreate. + This migration is only for preserving data during development. """ # Check if positions table exists and has simulation_run_id column cursor.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='positions'") @@ -300,23 +299,10 @@ def _migrate_schema(cursor: sqlite3.Cursor) -> None: columns = [row[1] for row in cursor.fetchall()] if 'simulation_run_id' not in columns: - # Add simulation_run_id column to existing positions table cursor.execute(""" ALTER TABLE positions ADD COLUMN simulation_run_id TEXT """) - # Check if jobs table exists and has warnings column - cursor.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='jobs'") - if cursor.fetchone(): - cursor.execute("PRAGMA table_info(jobs)") - columns = [row[1] for row in cursor.fetchall()] - - if 'warnings' not in columns: - # Add warnings column to existing jobs table - cursor.execute(""" - ALTER TABLE jobs ADD COLUMN warnings TEXT - """) - def _create_indexes(cursor: sqlite3.Cursor) -> None: """Create database indexes for query performance."""