This is an automated email from the ASF dual-hosted git repository.

ephraimanierobi 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 efaabd9c3f Explicitly name the primary keys in ORM for task & dagrun 
notes table (#27886)
efaabd9c3f is described below

commit efaabd9c3fc6840c8a3216ef496aeb3efb003682
Author: Ephraim Anierobi <[email protected]>
AuthorDate: Thu Nov 24 13:22:22 2022 +0100

    Explicitly name the primary keys in ORM for task & dagrun notes table 
(#27886)
    
    This was omitted but it's important for future migrations
---
 airflow/models/dagrun.py       | 2 ++
 airflow/models/taskinstance.py | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/airflow/models/dagrun.py b/airflow/models/dagrun.py
index d8f92d0099..205f2b82fe 100644
--- a/airflow/models/dagrun.py
+++ b/airflow/models/dagrun.py
@@ -32,6 +32,7 @@ from sqlalchemy import (
     Index,
     Integer,
     PickleType,
+    PrimaryKeyConstraint,
     String,
     Text,
     UniqueConstraint,
@@ -1322,6 +1323,7 @@ class DagRunNote(Base):
     dag_run = relationship("DagRun", back_populates="dag_run_note")
 
     __table_args__ = (
+        PrimaryKeyConstraint("dag_run_id", name="dag_run_note_pkey"),
         ForeignKeyConstraint(
             (dag_run_id,),
             ["dag_run.id"],
diff --git a/airflow/models/taskinstance.py b/airflow/models/taskinstance.py
index 201a7b6439..8b6197fe85 100644
--- a/airflow/models/taskinstance.py
+++ b/airflow/models/taskinstance.py
@@ -2808,6 +2808,9 @@ class TaskInstanceNote(Base):
     task_instance = relationship("TaskInstance", 
back_populates="task_instance_note")
 
     __table_args__ = (
+        PrimaryKeyConstraint(
+            "task_id", "dag_id", "run_id", "map_index", 
name="task_instance_note_pkey", mssql_clustered=True
+        ),
         ForeignKeyConstraint(
             (dag_id, task_id, run_id, map_index),
             [

Reply via email to