Skip to content

Commit

Permalink
Resolve warning in Dataset Alias migration
Browse files Browse the repository at this point in the history
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.

Example: https://github.com/apache/airflow/actions/runs/11526187767/job/32090094094?pr=43243#step:6:745

```
/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
```

I verified that both columns are marked as primary keys already in 2.10.
  • Loading branch information
kaxil committed Oct 27, 2024
1 parent e9192f5 commit 1ccd3cf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion docs/apache-airflow/img/airflow_erd.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
bda4fb36d2ac0f34e60a9969b6c1c1e6a98b555b0fc6d0e7bfcee9a89fb95fbf
6c7440c341ae96ec13058b9e983e9a4e51fdb28c8b603d9bdc9c1afd85089b38

0 comments on commit 1ccd3cf

Please sign in to comment.