Drupal core 8.5.6 database update failed due below error.
Drupal\Core\Database\DatabaseExceptionWrapper : SQLSTATE[42S02]: Base table or view not found: 1146 Table 'DEFAULT_DATABASE.CUSTOM_ENTITY_revision' doesn't exist: UPDATE {CUSTOM_ENTITY_revision} SET revision_created=:db_update_placeholder_0 WHERE vid = :db_condition_placeholder_0; Array ( [:db_update_placeholder_0] => 1506100764 [:db_condition_placeholder_0] => 2677 ) dans system_update_8400() (ligne 1963 de D:\drupal8-project\web\core\modules\system\system.install).
Actually "CUSTOM_ENTITY_revision" table exist in external_database, not in default_database.
Patch origin :
https://www.drupal.org/node/2248983
https://cgit.drupalcode.org/drupal/commit/core/modules/system/system.ins...
https://cgit.drupalcode.org/drupal/commit/core/modules/system/system.ins...
/**
+ * Move revision metadata fields to the revision table.
+ */
+function system_update_8302(&$sandbox) {
+ // Due to the fields from RevisionLogEntityTrait not being explicitly
+ // mentioned in the storage they might have been installed wrongly in the base
+ // table for revisionable untranslatable entities and in the data and revision
+ // data tables for revisionable and translatable entities.
+ $entity_definition_update_manager = \Drupal::entityDefinitionUpdateManager();
+ $database = \Drupal::database();
+ $database_schema = $database->schema();
$database object always pointing the default drupal database, while updating the drupal core 8.5.6, the execution got failed due to below error on database update(drush updb). its checking the revision table in default drupal database, not in the external database.
Please help us to resolve this issue, we recommend to do entity update by using entityTypeManager based on fixes, it will consider the relevant database.
FYI, we have configured the external database as per instruction in the below link (comments).
https://www.drupal.org/forum/support/module-development-and-code-questio...
Comments
Comment #2
vickey commentedComment #3
vickey commentedComment #4
cilefen commentedComment #5
vickey commentedHi cilefen,
Thanks for sharing the related post. Actually we already using this patch even though we are facing the issue.
We have shared our investigation summary in the comments.
--
Thanks
Vignesh.R
Comment #6
cilefen commentedIf #2990895: "Base table or view not found: 1146 Table 'default_db.entity_name_revision' " updating schema from drupal 8.3.5 to drupal 8.5.5 with entities stored in an external database fixes the issue then it should not have been marked "fixed". In fact, this issue should be marked a duplicate of #2990895.
Comment #7
vickey commentedBelow code will resolve our issue for connecting the external db for particular entity but we shouldn't hard any changes in drupal core file(system.install) so we are searching for general database connection which supports both default database and external database.
Please help us if there is any alternative to achieve this by using general solution.
Comment #8
cilefen commentedI am closing this as a duplicate of #2990895: "Base table or view not found: 1146 Table 'default_db.entity_name_revision' " updating schema from drupal 8.3.5 to drupal 8.5.5 with entities stored in an external database. Please move the discussion there.