diff --git a/backend/app/core/scheduler.py b/backend/app/core/scheduler.py index 3d5f5ff6..d25157c6 100644 --- a/backend/app/core/scheduler.py +++ b/backend/app/core/scheduler.py @@ -21,7 +21,7 @@ async def _fire_maintenance_schedule(schedule_id: str) -> None: """Create batch sessions for a scheduled maintenance run.""" # Import all models first to ensure SQLAlchemy mapper relationships resolve import app.models # noqa: F401 - from app.core.database import async_session_maker + from app.core.admin_database import _admin_session_factory as async_session_maker from app.models.maintenance_schedule import MaintenanceSchedule from app.models.session import Session from app.models.target_list import TargetList @@ -118,7 +118,7 @@ async def _fire_maintenance_schedule(schedule_id: str) -> None: async def _cleanup_expired_ai_conversations() -> None: """Delete expired AI wizard conversations.""" import app.models # noqa: F401 - from app.core.database import async_session_maker + from app.core.admin_database import _admin_session_factory as async_session_maker from app.models.ai_conversation import AIConversation async with async_session_maker() as db: diff --git a/backend/app/main.py b/backend/app/main.py index a9ade25e..795c0db9 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -25,7 +25,8 @@ if settings.SENTRY_DSN: ), ) -from app.core.database import init_db, async_session_maker +from app.core.database import init_db +from app.core.admin_database import _admin_session_factory as async_session_maker from app.core.logging_config import setup_logging from app.core.middleware import RequestLoggingMiddleware, ErrorLoggingMiddleware from app.core.security_headers import SecurityHeadersMiddleware diff --git a/backend/app/services/knowledge_flywheel_scheduler.py b/backend/app/services/knowledge_flywheel_scheduler.py index c1366b7d..65447f4b 100644 --- a/backend/app/services/knowledge_flywheel_scheduler.py +++ b/backend/app/services/knowledge_flywheel_scheduler.py @@ -10,7 +10,7 @@ import logging from sqlalchemy import select -from app.core.database import async_session_maker +from app.core.admin_database import _admin_session_factory as async_session_maker from app.models.ai_session import AISession from app.services.knowledge_flywheel import analyze_session diff --git a/backend/app/services/psa_retry_scheduler.py b/backend/app/services/psa_retry_scheduler.py index f3403eb2..03a32acd 100644 --- a/backend/app/services/psa_retry_scheduler.py +++ b/backend/app/services/psa_retry_scheduler.py @@ -9,7 +9,7 @@ from datetime import datetime, timezone from sqlalchemy import select from sqlalchemy.ext.asyncio import AsyncSession -from app.core.database import async_session_maker +from app.core.admin_database import _admin_session_factory as async_session_maker from app.models.psa_post_log import PsaPostLog from app.services.psa_documentation_service import retry_failed_push diff --git a/backend/app/services/retention_cleanup.py b/backend/app/services/retention_cleanup.py index c164240f..c8919451 100644 --- a/backend/app/services/retention_cleanup.py +++ b/backend/app/services/retention_cleanup.py @@ -9,7 +9,7 @@ from datetime import datetime, timezone, timedelta from sqlalchemy import select, delete, func -from app.core.database import async_session_maker +from app.core.admin_database import _admin_session_factory as async_session_maker from app.models.account import Account from app.models.assistant_chat import AssistantChat