feat: add sync columns and source_tree relationship to StepLibrary model
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -13,6 +13,7 @@ if TYPE_CHECKING:
|
||||
from app.models.account import Account
|
||||
from app.models.step_category import StepCategory
|
||||
from app.models.session import Session
|
||||
from app.models.tree import Tree
|
||||
|
||||
|
||||
class StepLibrary(Base):
|
||||
@@ -95,10 +96,26 @@ class StepLibrary(Base):
|
||||
# Soft delete
|
||||
is_active: Mapped[bool] = mapped_column(Boolean, nullable=False, default=True)
|
||||
|
||||
# Sync tracking (flow-sourced steps)
|
||||
source_tree_id: Mapped[Optional[uuid.UUID]] = mapped_column(
|
||||
UUID(as_uuid=True),
|
||||
ForeignKey('trees.id', ondelete='SET NULL'),
|
||||
nullable=True,
|
||||
index=True
|
||||
)
|
||||
source_node_id: Mapped[Optional[str]] = mapped_column(String(255), nullable=True)
|
||||
is_flow_synced: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
|
||||
last_synced_at: Mapped[Optional[datetime]] = mapped_column(DateTime(timezone=True), nullable=True)
|
||||
|
||||
# Relationships
|
||||
creator: Mapped["User"] = relationship("User", foreign_keys=[created_by])
|
||||
team: Mapped[Optional["Team"]] = relationship("Team")
|
||||
account: Mapped[Optional["Account"]] = relationship("Account", foreign_keys=[account_id], back_populates="step_library")
|
||||
source_tree: Mapped[Optional["Tree"]] = relationship(
|
||||
"Tree",
|
||||
foreign_keys=[source_tree_id],
|
||||
lazy="select"
|
||||
)
|
||||
category: Mapped[Optional["StepCategory"]] = relationship("StepCategory")
|
||||
ratings: Mapped[list["StepRating"]] = relationship("StepRating", back_populates="step", cascade="all, delete-orphan")
|
||||
usage_logs: Mapped[list["StepUsageLog"]] = relationship("StepUsageLog", back_populates="step", cascade="all, delete-orphan")
|
||||
|
||||
Reference in New Issue
Block a user