This is an automated email from the ASF dual-hosted git repository.
potiuk 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 2f32769bbb Fix unfound ab_user table in the CLI session (#34120)
2f32769bbb is described below
commit 2f32769bbb37236044f9c1ecb59809d82d0e3a62
Author: Hussein Awala <[email protected]>
AuthorDate: Wed Sep 6 23:06:39 2023 +0200
Fix unfound ab_user table in the CLI session (#34120)
---
airflow/models/dagrun.py | 11 +++++------
airflow/models/taskinstance.py | 10 ++++------
2 files changed, 9 insertions(+), 12 deletions(-)
diff --git a/airflow/models/dagrun.py b/airflow/models/dagrun.py
index 43ed97e518..11a6702747 100644
--- a/airflow/models/dagrun.py
+++ b/airflow/models/dagrun.py
@@ -1410,7 +1410,11 @@ class DagRunNote(Base):
__tablename__ = "dag_run_note"
- user_id = Column(Integer, nullable=True)
+ user_id = Column(
+ Integer,
+ nullable=True,
+ foreign_key=ForeignKey("ab_user.id", name="dag_run_note_user_fkey"),
+ )
dag_run_id = Column(Integer, primary_key=True, nullable=False)
content = Column(String(1000).with_variant(Text(1000), "mysql"))
created_at = Column(UtcDateTime, default=timezone.utcnow, nullable=False)
@@ -1426,11 +1430,6 @@ class DagRunNote(Base):
name="dag_run_note_dr_fkey",
ondelete="CASCADE",
),
- ForeignKeyConstraint(
- (user_id,),
- ["ab_user.id"],
- name="dag_run_note_user_fkey",
- ),
)
def __init__(self, content, user_id=None):
diff --git a/airflow/models/taskinstance.py b/airflow/models/taskinstance.py
index 82282eb39d..4919514c13 100644
--- a/airflow/models/taskinstance.py
+++ b/airflow/models/taskinstance.py
@@ -41,6 +41,7 @@ from sqlalchemy import (
Column,
DateTime,
Float,
+ ForeignKey,
ForeignKeyConstraint,
Index,
Integer,
@@ -3017,7 +3018,9 @@ class TaskInstanceNote(Base):
__tablename__ = "task_instance_note"
- user_id = Column(Integer, nullable=True)
+ user_id = Column(
+ Integer, nullable=True, foreign_key=ForeignKey("ab_user.id",
name="task_instance_note_user_fkey")
+ )
task_id = Column(StringID(), primary_key=True, nullable=False)
dag_id = Column(StringID(), primary_key=True, nullable=False)
run_id = Column(StringID(), primary_key=True, nullable=False)
@@ -3043,11 +3046,6 @@ class TaskInstanceNote(Base):
name="task_instance_note_ti_fkey",
ondelete="CASCADE",
),
- ForeignKeyConstraint(
- (user_id,),
- ["ab_user.id"],
- name="task_instance_note_user_fkey",
- ),
)
def __init__(self, content, user_id=None):