Compare commits

...

2 Commits

Author SHA1 Message Date
9813a3c9fd docs: add database migration strategy to v1.0.0 roadmap
Expand database migration strategy section to include:
- Automated schema migration system requirements
- Migration version tracking and rollback
- Zero-downtime migration procedures
- Pre-production recommendation to delete/recreate databases

Current state: Minimal migrations (pre-production)
Future: Full migration system for production deployments

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-02 08:42:38 -05:00
3535746eb7 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 <noreply@anthropic.com>
2025-11-02 07:23:58 -05:00
2 changed files with 11 additions and 17 deletions

View File

@@ -150,7 +150,15 @@ curl -X POST http://localhost:5000/simulate/to-date \
- Integration with monitoring systems (Prometheus, Grafana)
- Alerting recommendations
- Backup and disaster recovery guidance
- Database migration strategy
- Database migration strategy:
- Automated schema migration system for production databases
- Support for ALTER TABLE and table recreation when needed
- Migration version tracking and rollback capabilities
- Zero-downtime migration procedures for production
- Data integrity validation before and after migrations
- Migration script testing framework
- Note: Currently migrations are minimal (pre-production state)
- Pre-production recommendation: Delete and recreate databases for schema updates
- Upgrade path documentation (v0.x to v1.0)
- Version compatibility guarantees going forward

View File

@@ -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."""