31 lines
1.5 KiB
Python
31 lines
1.5 KiB
Python
import uuid
|
|
from datetime import datetime
|
|
|
|
from sqlalchemy import Boolean, DateTime, ForeignKey, String, Uuid, func
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
|
|
from app.database import Base
|
|
|
|
|
|
class Organization(Base):
|
|
__tablename__ = "organizations"
|
|
|
|
id: Mapped[uuid.UUID] = mapped_column(Uuid(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
|
user_id: Mapped[uuid.UUID] = mapped_column(Uuid(as_uuid=True), ForeignKey("users.id", ondelete="CASCADE"), unique=True)
|
|
name: Mapped[str] = mapped_column(String(255), nullable=False)
|
|
instagram: Mapped[str | None] = mapped_column(String(100))
|
|
email: Mapped[str | None] = mapped_column(String(255))
|
|
city: Mapped[str | None] = mapped_column(String(100))
|
|
logo_url: Mapped[str | None] = mapped_column(String(500))
|
|
verified: Mapped[bool] = mapped_column(Boolean, default=False, nullable=False)
|
|
# 'pending' | 'active' | 'rejected' | 'blocked'
|
|
status: Mapped[str] = mapped_column(String(20), nullable=False, default="pending")
|
|
block_reason: Mapped[str | None] = mapped_column(String(500))
|
|
created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
|
|
updated_at: Mapped[datetime] = mapped_column(
|
|
DateTime(timezone=True), server_default=func.now(), onupdate=func.now()
|
|
)
|
|
|
|
user: Mapped["User"] = relationship(back_populates="organization") # type: ignore[name-defined]
|
|
championships: Mapped[list["Championship"]] = relationship(back_populates="organization") # type: ignore[name-defined]
|