oshyun opened a new issue, #49557:
URL: https://github.com/apache/airflow/issues/49557

   ### Apache Airflow version
   
   2.10.5
   
   ### If "Other Airflow 2 version" selected, which one?
   
   _No response_
   
   ### What happened?
   
   When running `airflow db migrate --show-sql-only` on Airflow version 2.10.3 
or later, you may encounter the following error:
   
   ```
   AttributeError: 'MockConnection' object has no attribute 'close'
   ```
   
   ### The cause
   is related to the use of `insp = inspect(bind)` in offline mode. Since this 
is a dry-run operation (--show-sql-only), the process cannot properly load 
foreign key constraints through the `insp` object. 
   (related 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))
   
   
   
   ### What you think should happen instead?
   
   I understand that checking if the foreign key name exists in the existing 
database is necessary when renaming it. However, since this is offline mode, it 
would be more appropriate to generate the migration query under the assumption 
that the foreign key name already exists.
   
   
   
   ### How to reproduce
   
   To reproduce this issue on Airflow 2.10.3 or later, run any of the following 
commands:
   
   ```
   airflow db migrate --show-sql-only
   airflow db migrate --from-version 2.10.2 --to-version 2.10.3 --show-sql-only
   airflow db migrate --from-version 2.9.1 --to-version 2.10.5 --show-sql-only
   ```
   
   ### Operating System
   
   Debian GNU/Linux 12 (bookworm)
   
   ### Versions of Apache Airflow Providers
   
   _No response_
   
   ### Deployment
   
   Docker-Compose
   
   ### Deployment details
   
   _No response_
   
   ### Anything else?
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [x] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


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