Fix SQLAlchemy mapper init error — remove back_populates from Resos models

KDS uses a minimal Kitchen stub (no resos_* relationship properties) so
back_populates="resos_bookings" etc. caused mapper init to fail on every
request. Changed all four Resos.kitchen relationships to viewonly=True
with no back reference — KDS only reads these, not writes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-14 09:09:33 +00:00
parent cd434b3a19
commit c3d13446fc

View file

@ -48,7 +48,7 @@ class ResosBooking(Base):
is_forecast: Mapped[bool] = mapped_column(Boolean, default=False) is_forecast: Mapped[bool] = mapped_column(Boolean, default=False)
# Relationships # Relationships
kitchen: Mapped["Kitchen"] = relationship("Kitchen", back_populates="resos_bookings") kitchen: Mapped["Kitchen"] = relationship("Kitchen", viewonly=True)
__table_args__ = ( __table_args__ = (
UniqueConstraint('kitchen_id', 'resos_booking_id', name='uq_resos_booking'), UniqueConstraint('kitchen_id', 'resos_booking_id', name='uq_resos_booking'),
@ -87,7 +87,7 @@ class ResosDailyStats(Base):
is_forecast: Mapped[bool] = mapped_column(Boolean, default=False) is_forecast: Mapped[bool] = mapped_column(Boolean, default=False)
# Relationships # Relationships
kitchen: Mapped["Kitchen"] = relationship("Kitchen", back_populates="resos_daily_stats") kitchen: Mapped["Kitchen"] = relationship("Kitchen", viewonly=True)
__table_args__ = ( __table_args__ = (
UniqueConstraint('kitchen_id', 'date', name='uq_resos_daily_stat'), UniqueConstraint('kitchen_id', 'date', name='uq_resos_daily_stat'),
@ -113,7 +113,7 @@ class ResosOpeningHour(Base):
fetched_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow) fetched_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow)
# Relationships # Relationships
kitchen: Mapped["Kitchen"] = relationship("Kitchen", back_populates="resos_opening_hours") kitchen: Mapped["Kitchen"] = relationship("Kitchen", viewonly=True)
__table_args__ = ( __table_args__ = (
UniqueConstraint('kitchen_id', 'resos_opening_hour_id', name='uq_resos_opening_hour'), UniqueConstraint('kitchen_id', 'resos_opening_hour_id', name='uq_resos_opening_hour'),
@ -142,4 +142,4 @@ class ResosSyncLog(Base):
completed_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True) completed_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
# Relationships # Relationships
kitchen: Mapped["Kitchen"] = relationship("Kitchen", back_populates="resos_sync_logs") kitchen: Mapped["Kitchen"] = relationship("Kitchen", viewonly=True)