# /opt/docker/dev/service_finder/backend/app/db/base_class.py
from typing import Any
from sqlalchemy import MetaData
from sqlalchemy.orm import DeclarativeBase, declared_attr

# Globális séma beállítása
target_metadata = MetaData(schema="data")

class Base(DeclarativeBase):
    metadata = target_metadata
    
    # Automatikusan generálja a tábla nevét az osztálynévből
    @declared_attr.directive
    def __tablename__(cls) -> str:
        name = cls.__name__.lower()
        return f"{name}s" if not name.endswith('s') else name