|
| 1 | +# |
| 2 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 3 | +# or more contributor license agreements. See the NOTICE file |
| 4 | +# distributed with this work for additional information |
| 5 | +# regarding copyright ownership. The ASF licenses this file |
| 6 | +# to you under the Apache License, Version 2.0 (the |
| 7 | +# "License"); you may not use this file except in compliance |
| 8 | +# with the License. You may obtain a copy of the License at |
| 9 | +# |
| 10 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +# |
| 12 | +# Unless required by applicable law or agreed to in writing, |
| 13 | +# software distributed under the License is distributed on an |
| 14 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | +# KIND, either express or implied. See the License for the |
| 16 | +# specific language governing permissions and limitations |
| 17 | +# under the License. |
| 18 | + |
| 19 | +""" |
| 20 | +Add index to task_reschedule ti_id . |
| 21 | +
|
| 22 | +Revision ID: 82dbd68e6171 |
| 23 | +Revises: cc92b33c6709 |
| 24 | +Create Date: 2026-01-22 16:25:42.164449 |
| 25 | +
|
| 26 | +""" |
| 27 | + |
| 28 | +from __future__ import annotations |
| 29 | + |
| 30 | +from alembic import op |
| 31 | + |
| 32 | +# revision identifiers, used by Alembic. |
| 33 | +revision = "82dbd68e6171" |
| 34 | +down_revision = "cc92b33c6709" |
| 35 | +branch_labels = None |
| 36 | +depends_on = None |
| 37 | +airflow_version = "3.1.8" |
| 38 | + |
| 39 | + |
| 40 | +def upgrade(): |
| 41 | + """Add index to task_reschedule ti_id.""" |
| 42 | + with op.batch_alter_table("task_reschedule", schema=None) as batch_op: |
| 43 | + batch_op.create_index("idx_task_reschedule_ti_id", ["ti_id"], unique=False) |
| 44 | + |
| 45 | + |
| 46 | +def downgrade(): |
| 47 | + """Remove index from task_reschedule ti_id.""" |
| 48 | + dialect_name = op.get_context().dialect.name |
| 49 | + if dialect_name == "mysql": |
| 50 | + with op.batch_alter_table("task_reschedule", schema=None) as batch_op: |
| 51 | + batch_op.drop_constraint("task_reschedule_ti_fkey", type_="foreignkey") |
| 52 | + batch_op.drop_index("idx_task_reschedule_ti_id") |
| 53 | + batch_op.create_foreign_key( |
| 54 | + "task_reschedule_ti_fkey", "task_instance", ["ti_id"], ["id"], ondelete="CASCADE" |
| 55 | + ) |
| 56 | + else: |
| 57 | + with op.batch_alter_table("task_reschedule", schema=None) as batch_op: |
| 58 | + batch_op.drop_index("idx_task_reschedule_ti_id") |
0 commit comments