This is an automated email from the ASF dual-hosted git repository.
kalyanr pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 1f192bdd92e Add Deadline relationship to DagRun and update Deadline
model (#50925)
1f192bdd92e is described below
commit 1f192bdd92e82d527f76166d5957934145145f7e
Author: Kalyan R <[email protected]>
AuthorDate: Thu May 22 11:36:03 2025 +0530
Add Deadline relationship to DagRun and update Deadline model (#50925)
* Add Deadline relationship to DagRun and update Deadline model
* Refactor Deadline relationship in DagRun and Deadline models
* add test
* call it deadlines
* remove test
---
airflow-core/src/airflow/models/dagrun.py | 7 +++++++
airflow-core/src/airflow/models/deadline.py | 3 +++
2 files changed, 10 insertions(+)
diff --git a/airflow-core/src/airflow/models/dagrun.py
b/airflow-core/src/airflow/models/dagrun.py
index de742d4776f..5f17ff54709 100644
--- a/airflow-core/src/airflow/models/dagrun.py
+++ b/airflow-core/src/airflow/models/dagrun.py
@@ -256,6 +256,13 @@ class DagRun(Base, LoggingMixin):
cascade="all, delete, delete-orphan",
)
+ deadlines = relationship(
+ "Deadline",
+ back_populates="dagrun",
+ uselist=True,
+ cascade="all, delete, delete-orphan",
+ )
+
created_dag_version = relationship("DagVersion", uselist=False,
passive_deletes=True)
"""
The dag version that was active when the dag run was created, if available.
diff --git a/airflow-core/src/airflow/models/deadline.py
b/airflow-core/src/airflow/models/deadline.py
index b1d16f544ef..909e0567939 100644
--- a/airflow-core/src/airflow/models/deadline.py
+++ b/airflow-core/src/airflow/models/deadline.py
@@ -24,6 +24,7 @@ from typing import TYPE_CHECKING, Callable
import sqlalchemy_jsonfield
import uuid6
from sqlalchemy import Column, ForeignKey, Index, Integer, String
+from sqlalchemy.orm import relationship
from sqlalchemy_utils import UUIDType
from airflow.models.base import Base, StringID
@@ -56,6 +57,8 @@ class Deadline(Base):
# Serialized kwargs to pass to the callback.
callback_kwargs = Column(sqlalchemy_jsonfield.JSONField(json=json))
+ dagrun = relationship("DagRun", back_populates="deadlines")
+
__table_args__ = (Index("deadline_idx", deadline, unique=False),)
def __init__(