arkan-api / app /models /base.py
masry86's picture
initial commit - arkan backend
de0f1ef
raw
history blame contribute delete
607 Bytes
from datetime import datetime
from sqlalchemy import DateTime, func
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
class Base(DeclarativeBase):
pass
class TimestampMixin:
"""يُضاف لأي نموذج يحتاج created_at / updated_at."""
created_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True), server_default=func.now(), nullable=False
)
updated_at: Mapped[datetime | None] = mapped_column(
DateTime(timezone=True),
server_default=func.now(),
onupdate=func.now(),
nullable=True,
)