Initial commit with Phase 0 Scaffolding
This commit is contained in:
parent
b393607602
commit
c545d4b17d
51 changed files with 7064 additions and 4 deletions
32
backend/app/models/annotation_state.py
Normal file
32
backend/app/models/annotation_state.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
"""AnnotationState model — current working annotation layer per document."""
|
||||
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from sqlalchemy import ForeignKey, Text
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from app.db import Base
|
||||
|
||||
|
||||
def _now_iso() -> str:
|
||||
return datetime.now(timezone.utc).isoformat()
|
||||
|
||||
|
||||
class AnnotationState(Base):
|
||||
"""
|
||||
Current working annotation state for a document.
|
||||
|
||||
One row per document. `data` is a JSON text column containing
|
||||
the full annotation array — opaque to the server except during export.
|
||||
"""
|
||||
|
||||
__tablename__ = "annotation_states"
|
||||
|
||||
document_id: Mapped[str] = mapped_column(
|
||||
Text, ForeignKey("documents.id", ondelete="CASCADE"), primary_key=True
|
||||
)
|
||||
data: Mapped[str] = mapped_column(Text, default="[]") # JSON array
|
||||
updated_at: Mapped[str] = mapped_column(Text, default=_now_iso, onupdate=_now_iso)
|
||||
|
||||
# Relationships
|
||||
document: Mapped["Document"] = relationship("Document", back_populates="annotation_state")
|
||||
Loading…
Add table
Add a link
Reference in a new issue