ashb commented on code in PR #44790:
URL: https://github.com/apache/airflow/pull/44790#discussion_r1882483606


##########
airflow/migrations/versions/0029_3_0_0_remove_is_subdag.py:
##########
@@ -40,37 +41,23 @@
 airflow_version = "3.0.0"
 
 
-def _column_exists(inspector, column_name):
-    return column_name in [col["name"] for col in inspector.get_columns("dag")]
-
-
-def _index_exists(inspector, index_name):
-    return index_name in [index["name"] for index in 
inspector.get_indexes("dag")]
-
-
 def upgrade():
     """Remove ``is_subdag`` column from DAGs table."""
-    conn = op.get_bind()
-    inspector = sa.inspect(conn)
-
-    with op.batch_alter_table("dag", schema=None) as batch_op:
-        if _index_exists(inspector, "idx_root_dag_id"):
-            batch_op.drop_index("idx_root_dag_id")
-        if _column_exists(inspector, "is_subdag"):
-            batch_op.drop_column("is_subdag")
-        if _column_exists(inspector, "root_dag_id"):
-            batch_op.drop_column("root_dag_id")
+    dialect = op.get_bind().dialect.name
+    with op.batch_alter_table("dag") as batch_op:
+        batch_op.drop_column("is_subdag")
+        batch_op.drop_column("root_dag_id")
+        if op.get_bind().dialect.name == "mysql":
+            mysql_drop_index_if_exists("idx_root_dag_id", "dag", op)
+        elif dialect == "sqlite":
+            op.execute("""DROP INDEX idx_root_dag_id""")
+        else:
+            batch_op.drop_index("idx_root_dag_id", if_exists=True)

Review Comment:
   Why does sqlite need a different branch?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to