Lee-W commented on code in PR #43666:
URL: https://github.com/apache/airflow/pull/43666#discussion_r1831924578
##########
airflow/models/asset.py:
##########
@@ -284,6 +285,46 @@ def for_asset(cls, asset: AssetModel) -> AssetActive:
return cls(name=asset.name, uri=asset.uri)
+class TriggerAssetReference(Base):
+ """References from a trigger to an asset of which it is sending updates."""
+
+ trigger_id = Column(Integer, primary_key=True, nullable=False)
+ asset_id = Column(Integer, primary_key=True, nullable=False)
+
+ trigger = relationship("Trigger", back_populates="assets")
+ asset = relationship("AssetModel", back_populates="triggers")
+
+ __tablename__ = "trigger_asset_reference"
+ __table_args__ = (
+ PrimaryKeyConstraint(trigger_id, asset_id),
+ ForeignKeyConstraint(
+ columns=(trigger_id,),
+ refcolumns=["trigger.id"],
+ ondelete="CASCADE",
+ ),
+ ForeignKeyConstraint(
+ (asset_id,),
+ ["asset.id"],
+ ondelete="CASCADE",
+ ),
+ )
+
+ def __eq__(self, other):
+ if isinstance(other, self.__class__):
+ return self.trigger_id == other.trigger_id and self.asset_id ==
other.asset_id
+ else:
+ return NotImplemented
+
+ def __hash__(self):
Review Comment:
Thanks! I was suggested to add it when we needed it back to the time
DatasetAlias was introduced. It's easier for us to add new things then removing
ones.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]