Skip to content

Commit dd296c5

Browse files
Lee-Wutkarsharma2
authored andcommitted
This PR resolves an SQLAlchemy warning in the migration by correctly setting the alias_id column as part of the primary key in the dag_schedule_dataset_alias_reference table. Previously, only dag_id was marked as the primary key, causing a mismatch with the local definition, which triggered an SAWarning. (#43425)
Example: https://github.com/apache/airflow/actions/runs/11526187767/job/32090094094?pr=43243#step:6:745 When running a migration you see this. It was missed in #41264: ``` /opt/airflow/airflow/migrations/versions/0026_2_10_0_dag_schedule_dataset_alias_reference.py:46 SAWarning: Table 'dag_schedule_dataset_alias_reference' specifies columns 'dag_id' as primary_key=True, not matching locally specified columns 'alias_id', 'dag_id'; setting the current primary key columns to 'alias_id', 'dag_id'. This warning may become an exception in a future release ``` It is already a primary key in models: https://github.com/apache/airflow/blob/e9192f5db32e453f150c73ad31287d4953e3c43d/airflow/models/asset.py#L290-L291 Kaxil verified that both columns are marked as primary keys already in 2.10. (cherry picked from commit 72947cb)
1 parent 7557819 commit dd296c5

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

airflow/migrations/versions/0151_2_10_0_dag_schedule_dataset_alias_reference.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def upgrade():
4545
"""Add dag_schedule_dataset_alias_reference table."""
4646
op.create_table(
4747
"dag_schedule_dataset_alias_reference",
48-
sa.Column("alias_id", sa.Integer(), nullable=False),
48+
sa.Column("alias_id", sa.Integer(), primary_key=True, nullable=False),
4949
sa.Column("dag_id", StringID(), primary_key=True, nullable=False),
5050
sa.Column("created_at", airflow.utils.sqlalchemy.UtcDateTime(timezone=True), nullable=False),
5151
sa.Column("updated_at", airflow.utils.sqlalchemy.UtcDateTime(timezone=True), nullable=False),
+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3009a8ae271c281d59ada514c7181f1be4f0e2c6ba37148d4d5bf57502edf1d1
1+
f240c081c0e69e9c213b887cab50dc1b61e4a71010fcc2f177ab9e22adef229f

0 commit comments

Comments
 (0)