42 lines
1.4 KiB
Python
42 lines
1.4 KiB
Python
import uuid
|
|
from datetime import datetime
|
|
|
|
from sqlalchemy import DateTime, String, Text
|
|
from sqlalchemy.dialects.postgresql import UUID
|
|
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
|
|
|
|
|
|
class Base(DeclarativeBase):
|
|
pass
|
|
|
|
|
|
class Participant(Base):
|
|
__tablename__ = "participants"
|
|
|
|
id: Mapped[uuid.UUID] = mapped_column(
|
|
UUID(as_uuid=True), primary_key=True, default=uuid.uuid4
|
|
)
|
|
name: Mapped[str] = mapped_column(String(255), nullable=False)
|
|
email: Mapped[str] = mapped_column(String(255), nullable=False, unique=True)
|
|
timezone: Mapped[str] = mapped_column(String(50), nullable=False, default="America/Toronto")
|
|
ics_url: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
created_at: Mapped[datetime] = mapped_column(
|
|
DateTime, default=datetime.utcnow, nullable=False
|
|
)
|
|
updated_at: Mapped[datetime] = mapped_column(
|
|
DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False
|
|
)
|
|
|
|
|
|
class BusyBlock(Base):
|
|
__tablename__ = "busy_blocks"
|
|
|
|
id: Mapped[uuid.UUID] = mapped_column(
|
|
UUID(as_uuid=True), primary_key=True, default=uuid.uuid4
|
|
)
|
|
participant_id: Mapped[uuid.UUID] = mapped_column(
|
|
UUID(as_uuid=True), nullable=False, index=True
|
|
)
|
|
start_time: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False)
|
|
end_time: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False)
|