Operators sometimes run raw SQL against the POS database (GUI clients, psql, reports). Logs may show:
ERROR: relation "restaurantorder" does not exist
STATEMENT: SELECT table_id, COUNT(*) FROM restaurantorder ...
This codebase does not define a table named restaurantorder. That name usually comes from an external query, a different product’s schema, or a guess at the ORM name (RestaurantOrder → not used here).
| Concept | PostgreSQL identifier | Notes |
|---|---|---|
| Restaurant order (header: table, status, payment, …) | "order" |
order is a reserved word — use double quotes in SQL. |
| Order line items | orderitem |
Lowercase, unquoted is fine. |
| Physical tables (seats, floor plan) | "table" |
table is reserved — double quotes in SQL. |
Multi-tenant rows include tenant_id (and often deleted_at on orders). Filter by tenant when writing ad-hoc queries.
Wrong:
SELECT table_id, COUNT(*) FROM restaurantorder GROUP BY table_id HAVING COUNT(*) >= 1 LIMIT 10;Equivalent against this schema (adjust tenant_id as needed):
SELECT table_id, COUNT(*)
FROM "order"
WHERE tenant_id = 1 AND deleted_at IS NULL
GROUP BY table_id
HAVING COUNT(*) >= 1
LIMIT 10;-
Connection user: The database superuser is
POSTGRES_USER(defaultpos), notpostgres. If logs showFATAL: role "postgres" does not exist, fix the client DSN — see PostgreSQL: connecting from your machine in the root README.md. -
Schema source of truth: SQLModel models in
back/app/models.pyand versioned SQL underback/migrations/.