30 lines
941 B
Python
30 lines
941 B
Python
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from datetime import datetime
|
||
|
|
from uuid import UUID, uuid4
|
||
|
|
|
||
|
|
from sqlalchemy import UniqueConstraint
|
||
|
|
from sqlmodel import Field, SQLModel
|
||
|
|
|
||
|
|
from app.core.time import utcnow
|
||
|
|
|
||
|
|
|
||
|
|
class OrganizationMember(SQLModel, table=True):
|
||
|
|
__tablename__ = "organization_members"
|
||
|
|
__table_args__ = (
|
||
|
|
UniqueConstraint(
|
||
|
|
"organization_id",
|
||
|
|
"user_id",
|
||
|
|
name="uq_organization_members_org_user",
|
||
|
|
),
|
||
|
|
)
|
||
|
|
|
||
|
|
id: UUID = Field(default_factory=uuid4, primary_key=True)
|
||
|
|
organization_id: UUID = Field(foreign_key="organizations.id", index=True)
|
||
|
|
user_id: UUID = Field(foreign_key="users.id", index=True)
|
||
|
|
role: str = Field(default="member", index=True)
|
||
|
|
all_boards_read: bool = Field(default=False)
|
||
|
|
all_boards_write: bool = Field(default=False)
|
||
|
|
created_at: datetime = Field(default_factory=utcnow)
|
||
|
|
updated_at: datetime = Field(default_factory=utcnow)
|