mirror of
https://github.com/dat515-2025/Group-8.git
synced 2026-03-22 15:12:08 +01:00
fix(db): updated db setup for tests
This commit is contained in:
@@ -3,20 +3,11 @@ from fastapi import Depends
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from fastapi_users.db import SQLAlchemyUserDatabase
|
||||
|
||||
from ..core.db import async_session_maker, engine
|
||||
from ..core.base import Base
|
||||
from ..core.db import async_session_maker
|
||||
from ..models.user import User, OAuthAccount
|
||||
|
||||
_initialized = False
|
||||
|
||||
|
||||
async def get_async_session() -> AsyncGenerator[AsyncSession, None]:
|
||||
global _initialized
|
||||
if not _initialized:
|
||||
# Lazily ensure tables exist; helpful for test runs without migrations
|
||||
async with engine.begin() as conn:
|
||||
await conn.run_sync(Base.metadata.create_all)
|
||||
_initialized = True
|
||||
async with async_session_maker() as session:
|
||||
yield session
|
||||
|
||||
|
||||
Reference in New Issue
Block a user