-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
shri
committed
Jul 25, 2024
1 parent
84b64cd
commit 85002bd
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
from advanced_alchemy.base import SlugKey, UUIDAuditBase | ||
from sqlalchemy import String | ||
from sqlalchemy.orm import Mapped, mapped_column, relationship | ||
|
||
if TYPE_CHECKING: | ||
from .user import User | ||
|
||
|
||
class Tenant(UUIDAuditBase, SlugKey): | ||
"""A group of tenants i.e. a company or an organization.""" | ||
|
||
__tablename__ = "tenant" | ||
__pii_columns__ = {"name", "description", "url"} | ||
name: Mapped[str] = mapped_column(nullable=False, index=True) | ||
description: Mapped[str | None] = mapped_column(String(length=500), nullable=True, default=None) | ||
url: Mapped[str | None] = mapped_column(nullable=True, default=None) | ||
is_active: Mapped[bool] = mapped_column(default=True, nullable=False) | ||
# ----------- | ||
# ORM Relationships | ||
# ------------ | ||
users: Mapped[list[User]] = relationship( | ||
back_populates="tenant", | ||
innerjoin=True, | ||
lazy="selectin", | ||
) |