diff --git a/backend/src/module/database/engine.py b/backend/src/module/database/engine.py index 6ae8bb09..602f16f2 100644 --- a/backend/src/module/database/engine.py +++ b/backend/src/module/database/engine.py @@ -1,14 +1,12 @@ from sqlalchemy import event from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine from sqlalchemy.orm import sessionmaker -from sqlmodel import create_engine from module.conf import DATA_PATH -# Sync engine (used by Database, which owns a Session) -engine = create_engine(DATA_PATH) - -# Async engine (for passkey operations) +# The whole application runs on the async engine now. DATA_PATH (the sync +# sqlite URL) is kept only to derive the async URL and for the migration tests, +# which build their own throwaway sync engine. ASYNC_DATA_PATH = DATA_PATH.replace("sqlite:///", "sqlite+aiosqlite:///") async_engine = create_async_engine(ASYNC_DATA_PATH) async_session_factory = sessionmaker( @@ -16,13 +14,6 @@ async_session_factory = sessionmaker( ) -@event.listens_for(engine, "connect") -def _set_sqlite_fk_sync(dbapi_conn, connection_record): - cursor = dbapi_conn.cursor() - cursor.execute("PRAGMA foreign_keys=ON") - cursor.close() - - def _set_sqlite_pragmas_async(dbapi_conn, connection_record): """Per-connection SQLite pragmas for the async engine.