kaxil commented on code in PR #49873:
URL: https://github.com/apache/airflow/pull/49873#discussion_r2069238679
##########
airflow-core/src/airflow/migrations/versions/0028_3_0_0_drop_ab_user_id_foreign_key.py:
##########
@@ -38,54 +37,28 @@
airflow_version = "3.0.0"
-def table_exists(table_name):
- """Check if a table exists in the database."""
- inspector = inspect(op.get_bind())
- return table_name in inspector.get_table_names()
-
-
-def constraint_exists(table_name, constraint_name):
- """Check if a foreign key constraint exists on a table."""
- inspector = inspect(op.get_bind())
- foreign_keys = inspector.get_foreign_keys(table_name)
- return any(fk["name"] == constraint_name for fk in foreign_keys)
-
-
-def index_exists(table_name, index_name):
- """Check if an index exists on a table."""
- inspector = inspect(op.get_bind())
- indexes = inspector.get_indexes(table_name)
- return any(idx["name"] == index_name for idx in indexes)
-
-
def upgrade():
"""Apply Drop ab_user.id foreign key."""
- if constraint_exists("dag_run_note", "dag_run_note_user_fkey"):
- with op.batch_alter_table("dag_run_note", schema=None) as batch_op:
- batch_op.drop_constraint("dag_run_note_user_fkey",
type_="foreignkey")
-
- if constraint_exists("task_instance_note", "task_instance_note_user_fkey"):
- with op.batch_alter_table("task_instance_note", schema=None) as
batch_op:
- batch_op.drop_constraint("task_instance_note_user_fkey",
type_="foreignkey")
+ with op.batch_alter_table("dag_run_note", schema=None) as batch_op:
Review Comment:
Yeah, I have no context of why it was added
--
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]