Magento Setup upgrade error for smile elasticsuite database table not found error.

When you try to install the Magento smile elasticsuite extension to your system and on setup:upgrade command run time if you facing an error like Base Table or View not found error,

      • Base table or view not found: 1146 Table ‘magento.smile_elasticsuitecatalog_search_query_product_position’ doesn’t exist
      • BEGIN INSERT IGNORE INTO ‘catalogsearch_fulltext_cl’ (‘entity_id’) VALUES (NEW.’product_id’); END

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'magento.smile_elasticsuitecatalog_search_query_product_position' doesn't exist, query was: CREATE TRIGGER trg_smile_elasticsuitecat_srch_qr_prd_position_after_insert AFTER INSERT ON smile_elasticsuitecatalog_search_query_product_position FOR EACH ROW
BEGIN
INSERT IGNORE INTO `catalogsearch_fulltext_cl` (`entity_id`) VALUES (NEW.`product_id`);
END

You can fix it by applying the patch from the given GitHub link.

https://github.com/magento/magento2/pull/33092/files

A Patch file looks like,

--- a/magento/magento2-base/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php	2024-10-09 10:21:45.156058423 +0000
+++ b/magento/magento2-base/setup/src/Magento/Setup/Console/Command/UpgradeCommand.php	2024-10-09 10:20:55.142282329 +0000
@@ -31,7 +31,7 @@
     /**
      * Option to skip deletion of generated/code directory.
      */
-    const INPUT_KEY_KEEP_GENERATED = 'keep-generated';
+    public const INPUT_KEY_KEEP_GENERATED = 'keep-generated';

     /**
      * Installer service factory.
@@ -142,8 +142,8 @@
             $searchConfig = $this->searchConfigFactory->create();
             $this->cache->clean();
             $searchConfig->validateSearchEngine();
-            $installer->removeUnusedTriggers();
             $installer->installSchema($request);
+            $installer->removeUnusedTriggers();
             $installer->installDataFixtures($request, true);

             if ($this->deploymentConfig->isAvailable()) {

Using the above link, You can create a custom patch to apply in your system once patch is applied to the system. You can run the again setup:upgrade command.

You can able to run successfully upgrade command successfully without any errors.

Thank you.