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>
44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
"""
|
|
Migration script to add line item search capabilities:
|
|
- Enable pg_trgm extension for fuzzy text matching
|
|
- Create GIN index on line_items.description for trigram similarity
|
|
|
|
Run this script once after deploying the new code.
|
|
"""
|
|
import asyncio
|
|
import logging
|
|
from sqlalchemy import text
|
|
from database import engine
|
|
|
|
logging.basicConfig(level=logging.INFO)
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
async def run_migration():
|
|
"""Add pg_trgm extension and trigram index for line item search."""
|
|
logger.info("Running line item search migration...")
|
|
|
|
# Enable pg_trgm extension for fuzzy text matching
|
|
try:
|
|
async with engine.begin() as conn:
|
|
await conn.execute(text("CREATE EXTENSION IF NOT EXISTS pg_trgm"))
|
|
logger.info("Enabled pg_trgm extension")
|
|
except Exception as e:
|
|
logger.warning(f"pg_trgm extension: {e}")
|
|
|
|
# Create GIN index for trigram similarity on description
|
|
try:
|
|
async with engine.begin() as conn:
|
|
await conn.execute(text(
|
|
"CREATE INDEX IF NOT EXISTS ix_line_items_description_trgm "
|
|
"ON line_items USING gin (description gin_trgm_ops)"
|
|
))
|
|
logger.info("Created trigram index on line_items.description")
|
|
except Exception as e:
|
|
logger.warning(f"Trigram index: {e}")
|
|
|
|
logger.info("Line item search migration completed!")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(run_migration())
|