You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/01/28 17:04:55 UTC

[GitHub] [airflow] turbaszek commented on a change in pull request #13921: Fix DB Migration for SQLite to upgrade to 2.0

turbaszek commented on a change in pull request #13921:
URL: https://github.com/apache/airflow/pull/13921#discussion_r566258541



##########
File path: airflow/migrations/versions/cf5dc11e79ad_drop_user_and_chart.py
##########
@@ -47,7 +47,12 @@ def upgrade():  # noqa: D103
 
     if 'known_event' in tables:
         for fkey in inspector.get_foreign_keys(table_name="known_event", referred_table="users"):
-            op.drop_constraint(fkey['name'], 'known_event', type_="foreignkey")
+            if conn.dialect.name == "sqlite":
+                if fkey['name']:
+                    with op.batch_alter_table(table_name='known_event') as bop:
+                        bop.drop_constraint(fkey['name'], type_="foreignkey")
+            else:
+                op.drop_constraint(fkey['name'], 'known_event', type_="foreignkey")

Review comment:
       Won't `batch_alter_table` work for all? It seems to work for mysql at least:
   https://github.com/apache/airflow/blob/74da0faa7b85fe8a87d0a245179f8632fc93fd51/airflow/migrations/versions/74effc47d867_change_datetime_to_datetime2_6_on_mssql_.py#L52
   




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org