- New Calendar model and calendars table with system/default flags - Alembic migration 006: creates calendars, seeds Personal+Birthdays, migrates existing events - CalendarEvent model gains calendar_id FK and calendar_name/calendar_color properties - Updated CalendarEventCreate/Response schemas to include calendar fields - New /api/calendars CRUD router (blocks system calendar deletion/rename) - Events router: selectinload on all queries, default-calendar assignment on POST, virtual birthday event generation from People with birthdays when Birthdays calendar is visible Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
21 lines
988 B
Python
21 lines
988 B
Python
from sqlalchemy import String, Boolean, func
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
from datetime import datetime
|
|
from typing import List
|
|
from app.database import Base
|
|
|
|
|
|
class Calendar(Base):
|
|
__tablename__ = "calendars"
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True, index=True)
|
|
name: Mapped[str] = mapped_column(String(100), nullable=False)
|
|
color: Mapped[str] = mapped_column(String(20), nullable=False, default="#3b82f6")
|
|
is_default: Mapped[bool] = mapped_column(Boolean, default=False, server_default="false")
|
|
is_system: Mapped[bool] = mapped_column(Boolean, default=False, server_default="false")
|
|
is_visible: Mapped[bool] = mapped_column(Boolean, default=True, server_default="true")
|
|
created_at: Mapped[datetime] = mapped_column(default=func.now())
|
|
updated_at: Mapped[datetime] = mapped_column(default=func.now(), onupdate=func.now())
|
|
|
|
events: Mapped[List["CalendarEvent"]] = relationship(back_populates="calendar")
|