reaction-by-fix3
All checks were successful
Deploy on push / deploy (push) Successful in 47s

This commit is contained in:
2025-04-26 15:50:20 +03:00
parent 631ad47fe8
commit af7fbd2fc9
2 changed files with 7 additions and 9 deletions

View File

@@ -31,7 +31,7 @@ class Draft(Base):
__tablename__ = "draft"
# required
created_at: int = Column(Integer, nullable=False, default=lambda: int(time.time()))
# Переименовываем колонки ID, чтобы избежать конфликта имен с relationship
# Колонки для связей с автором
created_by: int = Column("created_by", ForeignKey("author.id"), nullable=False)
community: int = Column("community", ForeignKey("community.id"), nullable=False, default=1)
@@ -51,13 +51,11 @@ class Draft(Base):
# auto
updated_at: int | None = Column(Integer, nullable=True, index=True)
deleted_at: int | None = Column(Integer, nullable=True, index=True)
updated_by: int | None = Column("updated_by", ForeignKey("author.id"), nullable=True)
deleted_by: int | None = Column("deleted_by", ForeignKey("author.id"), nullable=True)
# --- Relationships ---
# Оставляем lazy="select" (по умолчанию) для коллекций, будем загружать их через joinedload в запросах
# Только many-to-many связи через вспомогательные таблицы
authors = relationship(Author, secondary="draft_author", lazy="select")
topics = relationship(Topic, secondary="draft_topic", lazy="select")