Skip to content

Commit ea1220d

Browse files
committed
Use keyword paramaters for migration methods for mssql
The new alembic (1.11.0) requires parameters to be keyword parameters in methods used in migrations. Part of the problem has been fixed in #31306 and #31302 but still some migrations that are specifically run in case of mssql need to use migration parameters.
1 parent 4dacab3 commit ea1220d

File tree

7 files changed

+25
-10
lines changed

7 files changed

+25
-10
lines changed

airflow/migrations/versions/0043_1_10_4_make_taskinstance_pool_not_nullable.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def upgrade():
6464

6565
conn = op.get_bind()
6666
if conn.dialect.name == "mssql":
67-
op.drop_index("ti_pool", table_name="task_instance")
67+
op.drop_index(index_name="ti_pool", table_name="task_instance")
6868

6969
# use batch_alter_table to support SQLite workaround
7070
with op.batch_alter_table("task_instance") as batch_op:
@@ -75,14 +75,16 @@ def upgrade():
7575
)
7676

7777
if conn.dialect.name == "mssql":
78-
op.create_index("ti_pool", "task_instance", ["pool", "state", "priority_weight"])
78+
op.create_index(
79+
index_name="ti_pool", table_name="task_instance", columns=["pool", "state", "priority_weight"]
80+
)
7981

8082

8183
def downgrade():
8284
"""Make TaskInstance.pool field nullable."""
8385
conn = op.get_bind()
8486
if conn.dialect.name == "mssql":
85-
op.drop_index("ti_pool", table_name="task_instance")
87+
op.drop_index(index_name="ti_pool", table_name="task_instance")
8688

8789
# use batch_alter_table to support SQLite workaround
8890
with op.batch_alter_table("task_instance") as batch_op:
@@ -93,7 +95,9 @@ def downgrade():
9395
)
9496

9597
if conn.dialect.name == "mssql":
96-
op.create_index("ti_pool", "task_instance", ["pool", "state", "priority_weight"])
98+
op.create_index(
99+
index_name="ti_pool", table_name="task_instance", columns=["pool", "state", "priority_weight"]
100+
)
97101

98102
with create_session() as session:
99103
session.query(TaskInstance).filter(TaskInstance.pool == "default_pool").update(

airflow/migrations/versions/0054_1_10_10_add_dag_code_table.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,15 @@ class SerializedDagModel(Base):
6363
conn = op.get_bind()
6464
if conn.dialect.name != "sqlite":
6565
if conn.dialect.name == "mssql":
66-
op.drop_index("idx_fileloc_hash", "serialized_dag")
66+
op.drop_index(index_name="idx_fileloc_hash", table_name="serialized_dag")
6767

6868
op.alter_column(
6969
table_name="serialized_dag", column_name="fileloc_hash", type_=sa.BigInteger(), nullable=False
7070
)
7171
if conn.dialect.name == "mssql":
72-
op.create_index("idx_fileloc_hash", "serialized_dag", ["fileloc_hash"])
72+
op.create_index(
73+
index_name="idx_fileloc_hash", table_name="serialized_dag", columns=["fileloc_hash"]
74+
)
7375

7476
sessionmaker = sa.orm.sessionmaker()
7577
session = sessionmaker(bind=conn)

airflow/migrations/versions/0060_2_0_0_remove_id_column_from_xcom.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def upgrade():
102102
if "id" in xcom_columns:
103103
if conn.dialect.name == "mssql":
104104
constraint_dict = get_table_constraints(conn, "xcom")
105-
drop_column_constraints(bop, "id", constraint_dict)
105+
drop_column_constraints(operator=bop, column_name="id", constraint_dict=constraint_dict)
106106
bop.drop_column("id")
107107
bop.drop_index("idx_xcom_dag_task_date")
108108
# mssql doesn't allow primary keys with nullable columns

airflow/migrations/versions/0089_2_2_0_make_xcom_pkey_columns_non_nullable.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ def upgrade():
4343
bop.alter_column("key", type_=StringID(length=512), nullable=False)
4444
bop.alter_column("execution_date", type_=TIMESTAMP, nullable=False)
4545
if conn.dialect.name == "mssql":
46-
bop.create_primary_key("pk_xcom", ["dag_id", "task_id", "key", "execution_date"])
46+
bop.create_primary_key(
47+
constraint_name="pk_xcom", columns=["dag_id", "task_id", "key", "execution_date"]
48+
)
4749

4850

4951
def downgrade():

airflow/migrations/versions/0102_2_3_0_switch_xcom_table_to_use_run_id.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,4 +172,8 @@ def downgrade():
172172
constraints = get_mssql_table_constraints(conn, "xcom")
173173
pk, _ = constraints["PRIMARY KEY"].popitem()
174174
op.drop_constraint(pk, "xcom", type_="primary")
175-
op.create_primary_key("pk_xcom", "xcom", ["dag_id", "task_id", "execution_date", "key"])
175+
op.create_primary_key(
176+
constraint_name="pk_xcom",
177+
table_name="xcom",
178+
columns=["dag_id", "task_id", "execution_date", "key"],
179+
)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4995c94849a5848e551e85ffeb99d3dda9f652f3c2d7b3cf3aa16c02911690d3
1+
4987842fd67d29e194f1117e127d3291ba60d3fbc3e81cba75ce93884c263321

setup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
# specific language governing permissions and limitations
1717
# under the License.
1818
"""Setup.py for the Airflow project."""
19+
# This file can be modified if you want to make sure the CI build is using "upgrade to newer dependencies"
20+
# Which is useful when you want to check if the dependencies are still compatible with the latest versions
21+
# And they seem to break some unrelated tests in main. You can modify this number = 00001 to trigger it.
1922
from __future__ import annotations
2023

2124
import glob

0 commit comments

Comments
 (0)