FastAPI backend (Python 3.11, MSSQL ODBC for SambaPOS, Azure DI OCR),
kitchen_db on central PG. React/TS/Vite frontend with navy sidebar layout.
Backend: auth.py (APP_SLUG=kitchen, SimpleNamespace — archive routes use
.kitchen_id/.is_admin without modification), main.py (51 migrations, scheduler,
internal router for KDS bookings feed), api/internal.py, full archive API
(31 routers: invoices, recipes, menus, sambapos, resos, newbook, disputes,
purchase_orders, etc.), models, migrations, OCR pipeline.
kitchen_id pinned to 1 (B1 — single hotel).
Frontend: AuthGate (app=kitchen, token shim for archive compat — B5b pending),
Layout (navy sidebar, 6 sections, Lucide icons, teal --app-primary),
App.tsx (Outlet pattern, UploadApp outside Layout), index.css (full :root block).
strict: false — archive components have type issues; build clean.
Note: 45 archive components call fetch('/api/...') without /kitchen/ prefix
(B5b). Runtime 404s; deferred until after initial testing.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
45 lines
1.9 KiB
Python
45 lines
1.9 KiB
Python
from datetime import datetime
|
|
from typing import Optional
|
|
from sqlalchemy import String, DateTime, ForeignKey, Text, Integer, BigInteger
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
from database import Base
|
|
|
|
|
|
class BackupHistory(Base):
|
|
"""Track backup history for each kitchen"""
|
|
__tablename__ = "backup_history"
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True, index=True)
|
|
kitchen_id: Mapped[int] = mapped_column(ForeignKey("kitchens.id"), nullable=False, index=True)
|
|
|
|
# Backup metadata
|
|
backup_type: Mapped[str] = mapped_column(String(20)) # "manual", "scheduled"
|
|
destination: Mapped[str] = mapped_column(String(20)) # "local", "nextcloud", "smb"
|
|
status: Mapped[str] = mapped_column(String(20)) # "running", "success", "failed"
|
|
|
|
# File information
|
|
filename: Mapped[str] = mapped_column(String(255)) # e.g., "backup_kitchen1_20260115_120000.zip"
|
|
file_path: Mapped[str] = mapped_column(String(500)) # Full path to backup file
|
|
file_size_bytes: Mapped[Optional[int]] = mapped_column(BigInteger, nullable=True)
|
|
|
|
# Statistics
|
|
invoice_count: Mapped[Optional[int]] = mapped_column(Integer, nullable=True)
|
|
file_count: Mapped[Optional[int]] = mapped_column(Integer, nullable=True)
|
|
|
|
# Timing
|
|
started_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow)
|
|
completed_at: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True)
|
|
|
|
# Error tracking
|
|
error_message: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
|
|
|
|
# User who triggered (null for scheduled)
|
|
triggered_by_user_id: Mapped[Optional[int]] = mapped_column(ForeignKey("users.id"), nullable=True)
|
|
|
|
# Relationships
|
|
kitchen: Mapped["Kitchen"] = relationship("Kitchen")
|
|
triggered_by_user: Mapped[Optional["User"]] = relationship("User")
|
|
|
|
|
|
# Forward references
|
|
from .user import Kitchen, User
|