- Configure Alembic for database migrations with initial schema - Fix base.py to use lazy loading for async engine (avoids import-time issues) - Change AI model from sonnet to haiku (claude-3-haiku-20240307) - Fix pytest version compatibility with pytest-asyncio - Add frontend package-lock.json Phase 1 tasks completed: - F1.1: Development environment (Docker, Node.js 20, Python 3.12, venv) - F1.2: PostgreSQL with 8 categories seeded - F1.3: Redis connection verified - F1.4: Anthropic API configured and tested - F1.5: Backend server + WebSocket verified Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
53 lines
1.3 KiB
Python
53 lines
1.3 KiB
Python
from logging.config import fileConfig
|
|
from sqlalchemy import engine_from_config, pool
|
|
from alembic import context
|
|
import sys
|
|
import os
|
|
|
|
# Add the backend directory to the path
|
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
from app.models.base import Base
|
|
from app.models import Category, Question, GameSession, GameEvent, Admin
|
|
|
|
config = context.config
|
|
if config.config_file_name is not None:
|
|
fileConfig(config.config_file_name)
|
|
|
|
target_metadata = Base.metadata
|
|
|
|
|
|
def run_migrations_offline() -> None:
|
|
url = config.get_main_option("sqlalchemy.url")
|
|
context.configure(
|
|
url=url,
|
|
target_metadata=target_metadata,
|
|
literal_binds=True,
|
|
dialect_opts={"paramstyle": "named"},
|
|
)
|
|
|
|
with context.begin_transaction():
|
|
context.run_migrations()
|
|
|
|
|
|
def run_migrations_online() -> None:
|
|
connectable = engine_from_config(
|
|
config.get_section(config.config_ini_section, {}),
|
|
prefix="sqlalchemy.",
|
|
poolclass=pool.NullPool,
|
|
)
|
|
|
|
with connectable.connect() as connection:
|
|
context.configure(
|
|
connection=connection, target_metadata=target_metadata
|
|
)
|
|
|
|
with context.begin_transaction():
|
|
context.run_migrations()
|
|
|
|
|
|
if context.is_offline_mode():
|
|
run_migrations_offline()
|
|
else:
|
|
run_migrations_online()
|