from sqlalchemy import create_engine
from sqlalchemy.orm import DeclarativeBase
from sqlalchemy.orm import sessionmaker

from app.core.config import settings

engine = create_engine(
    settings.database_url,
    echo=False
)

SessionLocal = sessionmaker(
    autocommit=False,
    autoflush=False,
    bind=engine
)


class Base(DeclarativeBase):
    pass

# <<< HIER IMPORTIEREN >>>
import app.models.rbac
import app.models.customer
import app.models.knowledge
import app.models.audit
import app.models.user


def get_db():
    db = SessionLocal()
    try:
        yield db
    finally:
        db.close()
