Calendar 모델도 User 모델에 대해 부모가 하나, 즉 서로에 대해 1:1 관계이므로 single_parent 설정을 추가해 주겠습니다.
파이썬(/appserver/apps/calendar/models.py)
# 생략
if TYPE_CHECKING:
from appserver.apps.account.models import User
class Calendar(SQLModel, table=True):
__tablename__ = "calendars"
# 생략
google_calendar_id: str = Field(max_length=1024, description="Google Calendar ID")
host_id: int = Field(foreign_key="users.id", unique=True) # ①
host: "User" = Relationship(
back_populates="calendar",
sa_relationship_kwargs={"uselist": False, "single_parent": True},
)