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

rom pushed a commit to branch v2-10-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v2-10-test by this push:
     new 72947cb0985 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)
72947cb0985 is described below

commit 72947cb09854f00d347b7c9cd09eb9ac89c75480
Author: Wei Lee <[email protected]>
AuthorDate: Mon Oct 28 17:02:28 2024 +0800

    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 
https://github.com/apache/airflow/pull/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.
---
 .../versions/0151_2_10_0_dag_schedule_dataset_alias_reference.py        | 2 +-
 docs/apache-airflow/img/airflow_erd.sha256                              | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/airflow/migrations/versions/0151_2_10_0_dag_schedule_dataset_alias_reference.py
 
b/airflow/migrations/versions/0151_2_10_0_dag_schedule_dataset_alias_reference.py
index a577a3eb781..a1a36b39705 100644
--- 
a/airflow/migrations/versions/0151_2_10_0_dag_schedule_dataset_alias_reference.py
+++ 
b/airflow/migrations/versions/0151_2_10_0_dag_schedule_dataset_alias_reference.py
@@ -45,7 +45,7 @@ def upgrade():
     """Add dag_schedule_dataset_alias_reference table."""
     op.create_table(
         "dag_schedule_dataset_alias_reference",
-        sa.Column("alias_id", sa.Integer(), nullable=False),
+        sa.Column("alias_id", sa.Integer(), primary_key=True, nullable=False),
         sa.Column("dag_id", StringID(), primary_key=True, nullable=False),
         sa.Column("created_at", 
airflow.utils.sqlalchemy.UtcDateTime(timezone=True), nullable=False),
         sa.Column("updated_at", 
airflow.utils.sqlalchemy.UtcDateTime(timezone=True), nullable=False),
diff --git a/docs/apache-airflow/img/airflow_erd.sha256 
b/docs/apache-airflow/img/airflow_erd.sha256
index 96c9ea1c16f..9ecc324f73a 100644
--- a/docs/apache-airflow/img/airflow_erd.sha256
+++ b/docs/apache-airflow/img/airflow_erd.sha256
@@ -1 +1 @@
-3009a8ae271c281d59ada514c7181f1be4f0e2c6ba37148d4d5bf57502edf1d1
\ No newline at end of file
+f240c081c0e69e9c213b887cab50dc1b61e4a71010fcc2f177ab9e22adef229f
\ No newline at end of file

Reply via email to