feat(core): add SoftDeleteMixin to db base, TenantMixin inherits from it
This commit is contained in:
@@ -30,6 +30,14 @@ class Base(DeclarativeBase):
|
||||
return self.__name__.lower() + "s"
|
||||
|
||||
|
||||
class SoftDeleteMixin:
|
||||
"""Adds deleted_at column for soft-delete support."""
|
||||
|
||||
deleted_at: Mapped[datetime | None] = mapped_column(
|
||||
DateTime(timezone=True), nullable=True, default=None
|
||||
)
|
||||
|
||||
|
||||
class TimestampMixin:
|
||||
"""Adds created_at and updated_at timestamps."""
|
||||
|
||||
@@ -41,7 +49,7 @@ class TimestampMixin:
|
||||
)
|
||||
|
||||
|
||||
class TenantMixin(TimestampMixin):
|
||||
class TenantMixin(TimestampMixin, SoftDeleteMixin):
|
||||
"""Adds tenant_id column and enables ORM-level auto-filtering."""
|
||||
|
||||
tenant_id: Mapped[uuid.UUID] = mapped_column(PGUUID(as_uuid=True), nullable=False, index=True)
|
||||
|
||||
Reference in New Issue
Block a user