This is an automated email from the ASF dual-hosted git repository. beto pushed a commit to branch fix-catalog-migration in repository https://gitbox.apache.org/repos/asf/superset.git
commit da1cf05753df5e665b2df22dd6e3625d748625cf Author: Beto Dealmeida <[email protected]> AuthorDate: Thu Oct 31 15:28:20 2024 -0400 fix: catalog migration w/o connection --- superset/migrations/shared/catalogs.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/superset/migrations/shared/catalogs.py b/superset/migrations/shared/catalogs.py index b75214291b..3f14598eb6 100644 --- a/superset/migrations/shared/catalogs.py +++ b/superset/migrations/shared/catalogs.py @@ -381,7 +381,17 @@ def upgrade_catalog_perms(engines: set[str] | None = None) -> None: # analytical DB. If we can't connect to the analytical DB during the migration # we should stop it, since we need the default catalog in order to update # existing models. - if default_catalog := database.get_default_catalog(): + try: + default_catalog = database.get_default_catalog() + except GenericDBException as ex: + logger.warning( + "Error fetching default catalog for database %s: %s", + database.database_name, + ex, + ) + continue + + if default_catalog: upgrade_database_catalogs(database, default_catalog, session) session.flush() @@ -558,7 +568,17 @@ def downgrade_catalog_perms(engines: set[str] | None = None) -> None: ) or not db_engine_spec.supports_catalog: continue - if default_catalog := database.get_default_catalog(): + try: + default_catalog = database.get_default_catalog() + except GenericDBException as ex: + logger.warning( + "Error fetching default catalog for database %s: %s", + database.database_name, + ex, + ) + continue + + if default_catalog: downgrade_database_catalogs(database, default_catalog, session) session.flush()
