feat: Sprint 6 polish - methodology, demo data, deployment prep
- Add policy event markers to time series charts - Create methodology page (/toronto/methodology) with data sources - Add demo data module for testing without full pipeline - Update README with project documentation - Add health check endpoint (/health) - Add database initialization script - Export new figure factory functions Closes #21 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
52
scripts/db/init_schema.py
Normal file
52
scripts/db/init_schema.py
Normal file
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Initialize database schema.
|
||||
|
||||
Usage:
|
||||
python scripts/db/init_schema.py
|
||||
|
||||
This script creates all SQLAlchemy tables in the database.
|
||||
Run this after docker-compose up to initialize the schema.
|
||||
"""
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
# Add project root to path
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent.parent))
|
||||
|
||||
from portfolio_app.toronto.models import create_tables, get_engine # noqa: E402
|
||||
|
||||
|
||||
def main() -> int:
|
||||
"""Initialize the database schema."""
|
||||
print("Initializing database schema...")
|
||||
|
||||
try:
|
||||
engine = get_engine()
|
||||
|
||||
# Test connection
|
||||
with engine.connect() as conn:
|
||||
result = conn.execute("SELECT 1")
|
||||
result.fetchone()
|
||||
print("Database connection successful")
|
||||
|
||||
# Create all tables
|
||||
create_tables()
|
||||
print("Schema created successfully")
|
||||
|
||||
# List created tables
|
||||
from sqlalchemy import inspect
|
||||
|
||||
inspector = inspect(engine)
|
||||
tables = inspector.get_table_names()
|
||||
print(f"Created tables: {', '.join(tables)}")
|
||||
|
||||
return 0
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error: {e}", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user