Phase 3.1: Enhanced Chore Logging and Reporting System
This commit is contained in:
19
backend/app/models/chore_assignment.py
Normal file
19
backend/app/models/chore_assignment.py
Normal file
@@ -0,0 +1,19 @@
|
||||
"""Chore Assignment model for many-to-many user-chore relationship."""
|
||||
from sqlalchemy import Column, Integer, DateTime, ForeignKey
|
||||
from sqlalchemy.orm import relationship
|
||||
from datetime import datetime
|
||||
from app.core.database import Base
|
||||
|
||||
class ChoreAssignment(Base):
|
||||
"""Junction table for assigning multiple users to chores."""
|
||||
__tablename__ = "chore_assignments"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
chore_id = Column(Integer, ForeignKey("chores.id", ondelete="CASCADE"), nullable=False)
|
||||
user_id = Column(Integer, ForeignKey("users.id", ondelete="CASCADE"), nullable=False)
|
||||
completed_at = Column(DateTime, nullable=True)
|
||||
created_at = Column(DateTime, default=datetime.utcnow)
|
||||
|
||||
# Relationships
|
||||
chore = relationship("Chore", back_populates="assignments")
|
||||
user = relationship("User", back_populates="chore_assignments")
|
||||
Reference in New Issue
Block a user