Repository: apache/superset
File: superset/initialization/__init__.py (Python)

Code before:
            category_icon="",
            category="Manage",
            category_label=_("Manage"),
        )

        appbuilder.add_view(
            RowLevelSecurityView,
            "Row Level Security",
            href="RowLevelSecurityView.list",
            label=_("Row Level Security"),
            category="Security",
            category_label=_("Security"),
            icon="fa-lock",
        )

    def init_app_in_ctx(self) -> None:
        """
        Runs init logic in the context of the app
        """
        self.configure_fab()
        self.configure_url_map_converters()
        self.configure_data_sources()
        self.configure_auth_provider()
        self.configure_async_queries()
        self.configure_ssh_manager()
        self.configure_stats_manager()

        # Hook that provides administrators a handle on the Flask APP
        # after initialization
        if flask_app_mutator := self.config["FLASK_APP_MUTATOR"]:
            flask_app_mutator(self.superset_app)

        if feature_flag_manager.is_feature_enabled("TAGGING_SYSTEM"):
            register_sqla_event_listeners()

        # Seed system themes from configuration
        try:
            from superset.commands.theme.seed import SeedSystemThemesCommand

            SeedSystemThemesCommand().run()
        except Exception:
            logger.exception("Failed to seed system themes")

        self.init_views()

    def check_secret_key(self) -> None:
        def log_default_secret_key_warning() -> None:
            top_banner = 80 * "-" + "\n" + 36 * " " + "WARNING\n" + 80 * "-"
            bottom_banner = 80 * "-" + "\n" + 80 * "-"
            logger.warning(top_banner)
            logger.warning(

Review comment (bug):
@mistercrunch @betodealmeida  This will fail for existing databases that don't have the `themes` table yet as the `dashboards` table will be there but not the `themes` one. Check https://github.com/apache/superset/issues/34403.

Code after:
            icon="fa-comment",
            category_icon="",
            category="Manage",
            category_label=_("Manage"),
        )

        appbuilder.add_view(
            RowLevelSecurityView,
            "Row Level Security",
            href="RowLevelSecurityView.list",
            label=_("Row Level Security"),
            category="Security",
            category_label=_("Security"),
            icon="fa-lock",
        )

    def _init_database_dependent_features(self) -> None:
        """
        Initialize features that require database tables to exist.
        This is called during app initialization but checks table existence
        to handle cases where the app starts before database migration.
        """
        inspector = inspect(db.engine)

        # Check if core tables exist (use 'dashboards' as proxy for Superset tables)
        if not inspector.has_table("dashboards"):
            logger.debug(
                "Superset tables not yet created. Skipping database-dependent "
                "initialization. These features will be initialized after migration."
            )
            return

        # Register SQLA event listeners for tagging system
        if feature_flag_manager.is_feature_enabled("TAGGING_SYSTEM"):
            register_sqla_event_listeners()

        # Seed system themes from configuration
        from superset.commands.theme.seed import SeedSystemThemesCommand

        SeedSystemThemesCommand().run()

    def init_app_in_ctx(self) -> None:
        """
        Runs init logic in the context of the app
        """
        self.configure_fab()
        self.configure_url_map_converters()
        self.configure_data_sources()
        self.configure_auth_provider()
        self.configure_async_queries()
        self.configure_ssh_manager()