- New cloud_backend/ FastAPI service on port 8001 (SQLite for dev, swappable to PostgreSQL) - Endpoints: sysadmin auth (JWT), site registration, lock/unlock, heartbeat (X-Site-ID + X-Site-Key headers) - Default sysadmin seeded on first startup from ADMIN_USERNAME/ADMIN_PASSWORD env vars - cloud_backend added to docker-compose.yml with persistent data volume at ./data/cloud/ - local_backend cloud_sync.py updated to use correct /api/heartbeat/ endpoint with header auth - local_backend config.py: added SITE_KEY setting - Smoke tested: login, register site, heartbeat, lock, unlock, list all pass
22 lines
897 B
Python
22 lines
897 B
Python
from sqlalchemy import 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)
|