from typing import TYPE_CHECKING, Optional from sqlmodel import Field, Relationship, SQLModel if TYPE_CHECKING: from app.models.organization import Organization class UserBase(SQLModel): email: str = Field(unique=True, index=True) name: str is_active: bool = Field(default=True) is_superadmin: bool = Field(default=False) class User(UserBase, table=True): __tablename__ = "users" id: Optional[int] = Field(default=None, primary_key=True) hashed_password: str organization_id: int = Field(foreign_key="organization.id", ondelete="RESTRICT") organization: "Organization" = Relationship(back_populates="users") class UserPublic(UserBase): id: int organization_id: int