refactor(backend): Alembic owns the local schema; v1 ALTER list deleted
Platform v2 step 1.0 (APPS_PLATFORM D-13, D-17). - migrations/ with env.py (render_as_batch, models/all.py metadata, no fileConfig) and baseline 0001_v2_baseline autogenerated from the models and reviewed; it also seeds the pos_settings rows a fresh v1 install got - core/schema.py::upgrade_to_head() is the only way the schema is built: app startup, seed.py, demo_seed.py, wipe_database.py and the tests. It refuses v1 databases (tables without alembic_version) with a clear error - main.py: _run_migrations() and create_all removed (723 lines) - sync_events became a model (was raw DDL); price_event_log order indexes declared on the model; unused order_discounts.price_before/after dropped - tests/guards: no-drift + idempotent upgrade + install defaults + v1 refusal + no create_all; placeholders for the time (1.1) and access (1.5) guards - CS-1 rewritten for Alembic on this branch Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
"""WebSocket replay buffer (F-014): every broadcast event gets a seq id the clients resume from.
|
||||
|
||||
Written and read with raw SQL in services/ws_bus.py (hot path, no ORM). The model
|
||||
exists so the table is part of the Alembic-managed schema.
|
||||
- sqlite_autoincrement: ids must never be reused after old rows are pruned, or a
|
||||
client's cursor could skip events.
|
||||
- created_at is an ISO string with offset (v1 audit, APPS_PLATFORM §7.4).
|
||||
>>> Step 1.1 converts it to the UTC datetime type.
|
||||
"""
|
||||
from sqlalchemy import Column, Integer, String, Text
|
||||
from database import Base
|
||||
|
||||
|
||||
class SyncEvent(Base):
|
||||
__tablename__ = "sync_events"
|
||||
__table_args__ = {"sqlite_autoincrement": True}
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
event_type = Column(String, nullable=False)
|
||||
payload = Column(Text, nullable=False)
|
||||
target_user_ids = Column(Text, nullable=True)
|
||||
created_at = Column(String, nullable=False, index=True)
|
||||
Reference in New Issue
Block a user