- Add docker-compose.yml with PostgreSQL 16 container (port 5433) - Create async database session factory with connection pooling - Configure SQLAlchemy 2.0 DeclarativeBase for models - Update .env.example with correct database URL Connection pool settings from research: pool_size=10, max_overflow=20, pool_recycle=1800 (30 min), pool_pre_ping=True for validation.
21 lines
635 B
Python
21 lines
635 B
Python
"""SQLAlchemy 2.0 declarative base for all models."""
|
|
|
|
from sqlalchemy.orm import DeclarativeBase
|
|
|
|
|
|
class Base(DeclarativeBase):
|
|
"""Base class for all SQLAlchemy models.
|
|
|
|
All models should inherit from this class for Alembic autogenerate
|
|
to discover them.
|
|
"""
|
|
|
|
pass
|
|
|
|
|
|
# Import all models here for Alembic autogenerate to discover them
|
|
# This ensures all models are registered with Base.metadata
|
|
# Note: Models are imported at the bottom to avoid circular imports
|
|
def import_models() -> None:
|
|
"""Import all models to register them with Base.metadata."""
|
|
from backend.app.db.models import build # noqa: F401
|