Skip to content

Commit 14564fb

Browse files
committed
feat: add TenantMixin for tenant_id column
1 parent 713692a commit 14564fb

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from uuid import UUID
2+
3+
from sqlalchemy import ForeignKey
4+
from sqlalchemy.dialects.postgresql import UUID as PG_UUID
5+
from sqlalchemy.orm import Mapped, mapped_column
6+
7+
8+
class TenantMixin:
9+
tenant_id: Mapped[UUID] = mapped_column(
10+
PG_UUID(as_uuid=True),
11+
ForeignKey("tenants.id"),
12+
nullable=False,
13+
sort_order=-60,
14+
)

src/shared/database/model.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from sqlalchemy.dialects.postgresql import UUID as PG_UUID
44
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
55

6+
from src.shared.database.mixin.tenant import TenantMixin # noqa: F401
7+
68

79
class Base(DeclarativeBase):
810
id: Mapped[UUID] = mapped_column(

0 commit comments

Comments
 (0)