From 02d5195c1c46337fef4287574df0f99f578c5b6f Mon Sep 17 00:00:00 2001 From: Leopoldadmin Date: Sat, 4 Jul 2026 00:31:44 +0000 Subject: [PATCH] feat(core): add SoftDeleteMixin to db base, TenantMixin inherits from it --- app/core/db/__init__.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/core/db/__init__.py b/app/core/db/__init__.py index 8455b40..620b2e6 100644 --- a/app/core/db/__init__.py +++ b/app/core/db/__init__.py @@ -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)