Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion airflow-core/docs/migrations-ref.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ Here's the list of all the Database Migrations that are executed via when you ru
+-------------------------+------------------+-------------------+--------------------------------------------------------------+
| Revision ID | Revises ID | Airflow Version | Description |
+=========================+==================+===================+==============================================================+
| ``c71065a1b14f`` (head) | ``ee86eed19e24`` | ``3.5.0`` | Add session_id and registration_id to Job. |
| ``38c8df3fcb9c`` (head) | ``c71065a1b14f`` | ``3.5.0`` | Add index on dag_run (dag_id, run_after). |
+-------------------------+------------------+-------------------+--------------------------------------------------------------+
| ``c71065a1b14f`` | ``ee86eed19e24`` | ``3.5.0`` | Add session_id and registration_id to Job. |
+-------------------------+------------------+-------------------+--------------------------------------------------------------+
| ``ee86eed19e24`` | ``9cffe90fa0c0`` | ``3.4.0`` | Add pending_partition_key to asset_partition_dag_run and |
| | | | enforce single pending row per key. |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

"""
Add index on dag_run (dag_id, run_after).

Revision ID: 38c8df3fcb9c
Revises: c71065a1b14f
Create Date: 2026-10-08 22:19:14.965383
"""

from __future__ import annotations

from alembic import op

# revision identifiers, used by Alembic.
revision = "38c8df3fcb9c"
down_revision = "c71065a1b14f"
branch_labels = None
depends_on = None
airflow_version = "3.5.0"


def upgrade():
"""Add index on dag_run (dag_id, run_after)."""
with op.batch_alter_table("dag_run", schema=None) as batch_op:
batch_op.create_index("idx_dag_run_dag_id_run_after", ["dag_id", "run_after"], unique=False)


def downgrade():
"""Remove index on dag_run (dag_id, run_after)."""
with op.batch_alter_table("dag_run", schema=None) as batch_op:
batch_op.drop_index("idx_dag_run_dag_id_run_after")
1 change: 1 addition & 0 deletions airflow-core/src/airflow/models/dagrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ class DagRun(Base, LoggingMixin):
UniqueConstraint("dag_id", "logical_date", name="dag_run_dag_id_logical_date_key"),
Index("idx_dag_run_dag_id", dag_id),
Index("idx_dag_run_run_after", run_after),
Index("idx_dag_run_dag_id_run_after", dag_id, run_after),
Index("idx_dag_run_created_dag_version_id", created_dag_version_id),
Index(
"idx_dag_run_running_dags",
Expand Down
2 changes: 1 addition & 1 deletion airflow-core/src/airflow/utils/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class MappedClassProtocol(Protocol):
"3.2.0": "1d6611b6ab7c",
"3.3.0": "d2f4e1b3c5a7",
"3.4.0": "ee86eed19e24",
"3.5.0": "c71065a1b14f",
"3.5.0": "38c8df3fcb9c",
}

# Prefix used to identify tables holding data moved during migration.
Expand Down