19 lines
709 B
Python
19 lines
709 B
Python
"""Daily Context Model - Stores subjective user inputs like mood, tags, etc."""
|
|
from sqlalchemy import Column, Integer, String, Date, ForeignKey, UniqueConstraint
|
|
from backend.database import Base
|
|
|
|
class DailyContext(Base):
|
|
__tablename__ = "daily_context"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
user_id = Column(Integer, ForeignKey("users.id"), index=True)
|
|
date = Column(Date, index=True)
|
|
|
|
mood_score = Column(Integer) # 1-100 slider
|
|
tags = Column(String, nullable=True) # Comma separated tags e.g. "Alcohol,Stress"
|
|
notes = Column(String, nullable=True)
|
|
|
|
__table_args__ = (
|
|
UniqueConstraint('user_id', 'date', name='uq_daily_context'),
|
|
)
|