This is an automated email from the ASF dual-hosted git repository. ephraimanierobi pushed a commit to branch v2-3-test in repository https://gitbox.apache.org/repos/asf/airflow.git
commit 5c2fce92f46479c6948c358ab675dd41b3d177fd Author: Ash Berlin-Taylor <[email protected]> AuthorDate: Mon Aug 1 13:58:31 2022 +0100 Fix `airflow db reset` when dangling tables exist (#25441) If one of the "dangling" tables already existed in the DB, performing an `airflow db reset` would delete the tables, but it would then try and _re-create_ the table later. This was because the Table object was still associated with the Metadata object. The fix is to remove the it from Metadata once we have dropped it. (cherry picked from commit 40eefd84797f5085e6c3fef6cbd6f713ceb3c3d8) --- airflow/utils/db.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/airflow/utils/db.py b/airflow/utils/db.py index a86222e3b8..192a2343c4 100644 --- a/airflow/utils/db.py +++ b/airflow/utils/db.py @@ -1582,7 +1582,8 @@ def drop_airflow_moved_tables(session): tables = set(inspect(session.get_bind()).get_table_names()) to_delete = [Table(x, Base.metadata) for x in tables if x.startswith(AIRFLOW_MOVED_TABLE_PREFIX)] for tbl in to_delete: - tbl.drop(settings.engine, checkfirst=True) + tbl.drop(settings.engine, checkfirst=False) + Base.metadata.remove(tbl) def drop_flask_models(connection):
