Record a StrikeEvent row whenever a strike is added or removed, and surface them in the activity log timeline with timestamp, child name, and whether the strike was added or removed. - New strike_events table (auto-created on startup) - children router records prev/new strikes on every update - GET /api/logs/strikes and DELETE /api/logs/strikes/:id endpoints - Log view merges strike entries into the timeline (red dot, "✕ Strike added (2/3)" / "↩ Strike removed (1/3)") Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
19 lines
740 B
Python
19 lines
740 B
Python
from datetime import datetime
|
|
|
|
from sqlalchemy import DateTime, ForeignKey, Integer, func
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
|
|
from app.models.base import Base
|
|
|
|
|
|
class StrikeEvent(Base):
|
|
__tablename__ = "strike_events"
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
|
child_id: Mapped[int] = mapped_column(ForeignKey("children.id", ondelete="CASCADE"), nullable=False)
|
|
occurred_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now(), nullable=False)
|
|
prev_strikes: Mapped[int] = mapped_column(Integer, nullable=False)
|
|
new_strikes: Mapped[int] = mapped_column(Integer, nullable=False)
|
|
|
|
child: Mapped["Child"] = relationship("Child") # noqa: F821
|