diff --git a/.env-example b/.env-example index dcebda3..f98060c 100644 --- a/.env-example +++ b/.env-example @@ -30,8 +30,10 @@ SMTP_HOST= SMTP_PORT=587 SMTP_USER= SMTP_PASSWORD= -SMTP_TLS=True # Use TLS for email security -SMTP_SSL=False # Set to True if using SSL instead of TLS +# Use TLS for email security +SMTP_TLS=True +# Set to True if using SSL instead of TLS +SMTP_SSL=False # Email sender information EMAILS_FROM_EMAIL= diff --git a/backend/app/api/routes/utils_routes.py b/backend/app/api/routes/utils_routes.py index 9a920f9..1a44ee8 100644 --- a/backend/app/api/routes/utils_routes.py +++ b/backend/app/api/routes/utils_routes.py @@ -1,8 +1,12 @@ +import logging + from sqlmodel import select from fastapi import APIRouter from app.api.dependencies import SessionDep +logger = logging.getLogger(__name__) + router = APIRouter(prefix="/utils", tags=["utils"]) @@ -10,11 +14,12 @@ router = APIRouter(prefix="/utils", tags=["utils"]) async def health_check() -> bool: return True + @router.get("/test-db/") async def test_db(session: SessionDep) -> bool: try: - with session: - session.exec(select(1)) - return True - except Exception: + session.exec(select(1)) + return True + except Exception as e: + logger.error(e) return False diff --git a/backend/app/database/manager.py b/backend/app/database/manager.py index a1b3699..3f6636e 100644 --- a/backend/app/database/manager.py +++ b/backend/app/database/manager.py @@ -9,7 +9,7 @@ from app.core.config import settings from app.database.exceptions import DatabaseError -import app.database.models +import app.database.models # pylint: disable=unused-import logger = logging.getLogger(__name__) @@ -34,7 +34,6 @@ def cleanup() -> None: engine.dispose() -@contextmanager def get_session() -> Generator[Session, None, None]: with Session(engine) as session: yield session diff --git a/backend/app/database/models/user_model.py b/backend/app/database/models/user_model.py index 1eafb88..8d8e567 100644 --- a/backend/app/database/models/user_model.py +++ b/backend/app/database/models/user_model.py @@ -26,7 +26,7 @@ class User(SQLModel, table=True): owned_shops: List["Shop"] = Relationship(back_populates="owner") registered_shop: List["Shop"] = Relationship(back_populates="registered_users") - role: Optional["UserRole"] = Relationship(back_populates="users") + user_assigned_role: Optional["UserRole"] = Relationship(back_populates="role_users", sa_relationship_kwargs={"foreign_keys": "[User.user_role_id]"}) preferences: Optional["UserPreferences"] = Relationship(back_populates="user") statistics: Optional["UserStatistics"] = Relationship(back_populates="user_statistics") @@ -45,7 +45,7 @@ class UserRole(SQLModel, table=True): id: int = Field(primary_key=True) name: str = Field(nullable=False, unique=True, max_length=50) - users = Relationship(back_populates="role") + role_users: List["User"] = Relationship(back_populates="user_assigned_role") class UserStatistics(SQLModel, table=True):