ashb commented on code in PR #62234:
URL: https://github.com/apache/airflow/pull/62234#discussion_r2914988651
##########
airflow-core/src/airflow/utils/db.py:
##########
@@ -1291,9 +1305,40 @@ def _resetdb_default(session: Session) -> None:
external_db_manager.drop_tables(session, connection)
+def _drop_remaining_tables() -> None:
+ """
+ Drop any tables still remaining in the database after the normal reset.
+
+ The squashed migration (0000_2_6_2) creates tables like FAB ab_* tables
that
+ are now managed by external auth managers. When the default auth manager
+ (SimpleAuthManager) has no DB manager, those tables are not dropped by
+ external_db_manager.drop_tables(). This function reflects the actual
database
+ and drops anything left over so the migration has a clean slate.
+ """
+ from sqlalchemy import MetaData
+
+ engine = settings.get_engine()
+ metadata = MetaData()
+ metadata.reflect(bind=engine)
+ if not metadata.tables:
+ return
+ remaining = list(metadata.tables.keys())
Review Comment:
Dropping tables sounds very dangerous
--
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]