Platform v2 step 1.7 (APPS_PLATFORM D-3, D-20, D-21, D-22, §5.2).
- Alembic replaces create_all + _run_migrations. 0001_cloud_baseline is
exactly the v1 production schema (incl. the dead menu_hours_en/_gr), checked
against a frozen fixture; schema.py refuses an unstamped v1 DB, so prod is
stamped once at cutover (DEPLOYMENT_GUIDE Part 6)
- 0002_v2_licensing: sites.modules (JSON), sites.module_catalog(_at),
plan_presets; existing sites get every module v1 had (KDS unlimited); the
same map is seeded as preset "Everything (v1 sites)"; dead columns dropped
- license token v: 2 with a normalized `modules` map
- heartbeat v2: request {version, local_ip, module_catalog} (catalogue stored
per site); response {license_token, latest_version, waiter_domain,
site_numeric_id} - the unsigned v1 license fields are gone
- sites API: create with a preset, PUT /{id}/modules (validated),
POST /{id}/apply-preset/{preset}; /api/presets CRUD
- sysadmin panel: Licensed modules card per site (built from the reported
catalogue, fallback list), preset picker on register, Presets page
- .dockerignore: local *.db, .env and tests no longer baked into the image
- tests (new): baseline = v1, unstamped refused, stamp+upgrade of a v1 DB,
drift, token v2 shape/signature, module edits, presets; CL-2/CL-7 rules
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
44 lines
2.1 KiB
Python
44 lines
2.1 KiB
Python
from sqlalchemy import JSON, Column, Integer, String, Boolean, DateTime
|
|
from sqlalchemy.sql import func
|
|
from database import Base
|
|
|
|
|
|
class Site(Base):
|
|
__tablename__ = "sites"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
site_id = Column(String, unique=True, nullable=False, index=True)
|
|
name = Column(String, nullable=False)
|
|
owner_name = Column(String, nullable=False)
|
|
contact_email = Column(String, nullable=False)
|
|
secret_key_hash = Column(String, nullable=False)
|
|
is_active = Column(Boolean, default=True)
|
|
is_locked = Column(Boolean, default=False)
|
|
lock_reason = Column(String, nullable=True)
|
|
license_expires_at = Column(DateTime(timezone=True), nullable=False)
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
last_seen_at = Column(DateTime(timezone=True), nullable=True)
|
|
last_seen_ip = Column(String, nullable=True)
|
|
last_seen_local_ip = Column(String, nullable=True)
|
|
waiter_domain = Column(String, nullable=True)
|
|
# Monotonically incrementing counter used to generate public_ref for online orders
|
|
order_counter = Column(Integer, default=0, nullable=False)
|
|
|
|
# QR menu branding/config
|
|
menu_mode = Column(String, nullable=False, default="order") # "order" | "view_only"
|
|
menu_display_name = Column(String, nullable=True)
|
|
menu_tagline_en = Column(String, nullable=True)
|
|
menu_tagline_gr = Column(String, nullable=True)
|
|
menu_blurb_en = Column(String, nullable=True)
|
|
menu_blurb_gr = Column(String, nullable=True)
|
|
menu_hours = Column(String, nullable=True)
|
|
menu_header_image_url = Column(String, nullable=True)
|
|
|
|
# Licensed modules (APPS_PLATFORM D-3, §5.2): the `modules` map of the site's v2 license
|
|
# token, e.g. {"ordering": {}, "kds": {"limits": {"devices": 2}}, "caller_id": {"exp": "..."}}.
|
|
# Edited in the sysadmin panel, usually by applying a plan preset first.
|
|
modules = Column(JSON, nullable=False, default=dict)
|
|
# What the site reported it can run (heartbeat `module_catalog`, D-20): drives the editor.
|
|
module_catalog = Column(JSON, nullable=True)
|
|
module_catalog_at = Column(DateTime(timezone=True), nullable=True)
|