"""Essential model — actionable items under a Proposal. Each Essential represents one deliverable scope item (feature, improvement, or refactor). When a Proposal is accepted, every Essential is converted into a corresponding ``story/*`` task under the chosen Milestone. See: NEXT_WAVE_DEV_DIRECTION.md §8.5 """ from sqlalchemy import Column, Integer, String, Text, DateTime, ForeignKey, Enum from sqlalchemy.sql import func from app.core.config import Base import enum class EssentialType(str, enum.Enum): FEATURE = "feature" IMPROVEMENT = "improvement" REFACTOR = "refactor" class Essential(Base): __tablename__ = "essentials" id = Column(Integer, primary_key=True, index=True) essential_code = Column( String(64), nullable=False, unique=True, index=True, comment="Unique human-readable code, e.g. PROJ:E00001", ) proposal_id = Column( Integer, ForeignKey("proposes.id"), # FK targets the actual DB table name nullable=False, comment="Owning Proposal", ) type = Column( Enum(EssentialType, values_callable=lambda x: [e.value for e in x]), nullable=False, comment="Essential type: feature | improvement | refactor", ) title = Column(String(255), nullable=False, comment="Short title") description = Column(Text, nullable=True, comment="Detailed description") created_by_id = Column( Integer, ForeignKey("users.id"), nullable=True, comment="Author of the essential", ) created_at = Column(DateTime(timezone=True), server_default=func.now()) updated_at = Column(DateTime(timezone=True), onupdate=func.now())