oshyun commented on issue #49557: URL: https://github.com/apache/airflow/issues/49557#issuecomment-2821525971
I'm planning to resolve this issue by patching [the code](https://github.com/apache/airflow/blob/2.10.5/airflow/migrations/versions/0152_2_10_3_fix_dag_schedule_dataset_alias_reference_naming.py) as shown below: ``` @@ -67,9 +67,15 @@ def upgrade(): """Rename dag_schedule_dataset_alias_reference constraint.""" with op.batch_alter_table("dag_schedule_dataset_alias_reference", schema=None) as batch_op: - bind = op.get_context().bind - insp = inspect(bind) - fk_constraints = [fk["name"] for fk in insp.get_foreign_keys("dag_schedule_dataset_alias_reference")] + + fk_constraints = [] + if not op.get_context().environment_context.is_offline_mode(): + bind = op.get_context().bind + insp = inspect(bind) + fk_constraints = [fk["name"] for fk in insp.get_foreign_keys("dag_schedule_dataset_alias_reference")] + else: + # Assume constraints exist in offline mode + fk_constraints = ["dsdar_dataset_fkey", "dsdar_dag_fkey"] # "dsdar_dataset_alias_fkey" was the constraint name defined in the model while "dsdar_dataset_fkey" is the one # defined in the previous migration. @@ -103,9 +109,16 @@ def downgrade(): """Undo dag_schedule_dataset_alias_reference constraint rename.""" with op.batch_alter_table("dag_schedule_dataset_alias_reference", schema=None) as batch_op: - bind = op.get_context().bind - insp = inspect(bind) - fk_constraints = [fk["name"] for fk in insp.get_foreign_keys("dag_schedule_dataset_alias_reference")] + + fk_constraints = [] + if not op.get_context().environment_context.is_offline_mode(): + bind = op.get_context().bind + insp = inspect(bind) + fk_constraints = [fk["name"] for fk in insp.get_foreign_keys("dag_schedule_dataset_alias_reference")] + else: + # Assume constraints exist in offline mode + fk_constraints = ["dsdar_dataset_alias_fkey", "dsdar_dag_id_fkey"] + if "dsdar_dataset_alias_fkey" in fk_constraints: _rename_fk_constraint( batch_op=batch_op, ``` -- 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]
