fix unresolved links on sync

This commit is contained in:
phernandez
2025-01-22 22:37:34 -06:00
parent 23922f2915
commit 9f35f8b8d2
12 changed files with 728 additions and 23 deletions
+7 -3
View File
@@ -10,7 +10,6 @@ from sqlalchemy import (
Text,
ForeignKey,
UniqueConstraint,
text,
DateTime,
Index,
JSON,
@@ -185,7 +184,10 @@ class Relation(Base):
id: Mapped[int] = mapped_column(Integer, primary_key=True)
from_id: Mapped[int] = mapped_column(Integer, ForeignKey("entity.id", ondelete="CASCADE"))
to_id: Mapped[int] = mapped_column(Integer, ForeignKey("entity.id", ondelete="CASCADE"))
to_id: Mapped[int] = mapped_column(
Integer, ForeignKey("entity.id", ondelete="CASCADE"), nullable=True
)
to_name: Mapped[str] = mapped_column(String)
relation_type: Mapped[str] = mapped_column(String)
context: Mapped[str] = mapped_column(Text, nullable=True)
created_at: Mapped[datetime] = mapped_column(DateTime)
@@ -206,7 +208,9 @@ class Relation(Base):
return generate_permalink(
f"{self.from_entity.permalink}/{self.relation_type}/{self.to_entity.permalink}"
if self.to_entity
else f"{self.from_entity.permalink}/{self.relation_type}"
)
def __repr__(self) -> str:
return f"Relation(id={self.id}, from_id={self.from_id}, to_id={self.to_id}, type='{self.relation_type}')"
return f"Relation(id={self.id}, from_id={self.from_id}, to_id={self.to_id}, type='{self.relation_type}')"