Problem/Motivation
When attempting to edit some content, I get this error: "Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'my_database.commerce_license__file_download_limit' doesn't exist: SELECT t.* FROM {commerce_license__file_download_limit} t WHERE (entity_id IN (:db_condition_placeholder_0, :db_condition_placeholder_1, :db_condition_placeholder_2, :db_condition_placeholder_3, :db_condition_placeholder_4, :db_condition_placeholder_5, :db_condition_placeholder_6, :db_condition_placeholder_7, :db_condition_placeholder_8, :db_condition_placeholder_9, :db_condition_placeholder_10, :db_condition_placeholder_11, :db_condition_placeholder_12)) AND (deleted = :db_condition_placeholder_13) AND (langcode IN (:db_condition_placeholder_14, :db_condition_placeholder_15, :db_condition_placeholder_16, :db_condition_placeholder_17)) ORDER BY delta ASC; Array ( [:db_condition_placeholder_0] => 2 [:db_condition_placeholder_1] => 6 [:db_condition_placeholder_2] => 8 [:db_condition_placeholder_3] => 13 [:db_condition_placeholder_4] => 14 [:db_condition_placeholder_5] => 15 [:db_condition_placeholder_6] => 16 [:db_condition_placeholder_7] => 21 [:db_condition_placeholder_8] => 22 [:db_condition_placeholder_9] => 23 [:db_condition_placeholder_10] => 24 [:db_condition_placeholder_11] => 25 [:db_condition_placeholder_12] => 26 [:db_condition_placeholder_13] => 0 [:db_condition_placeholder_14] => en [:db_condition_placeholder_15] => fr [:db_condition_placeholder_16] => und [:db_condition_placeholder_17] => zxx ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->loadFromDedicatedTables() (line 1261 of .../web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
Steps to reproduce
I don't know whether this issue is related to Commerce File or Commerce License, but I did recently "upgrade" Commerce File with Composer to 8.x-2.0-beta3. I had the module installed for quite some time, but it was not managed by Composer. (I think that's a recent improvement to the module?)
I've looked at some backups of the site's database from a year ago, and I don't think such a table ever existed.
Comments
Comment #2
msypes commentedBased on a recommendation from @jsacksick in the Slack Commerce support channel, I created a
hook_update_Nwith the following code:Ran
drush updb, and it seems to have solved the problem. The missing table is now present.Comment #3
jsacksick commentedComment #5
RGonski commentedHi,
I'm having the same issue which is having a lot of knock on effects on other things too so I have to resolve it.
I've read the above but trying to work out how one goes about creating a hook_deploy_n and deploying the code.
Would appreciate any pointers in the right direction.
Thanks!
Comment #6
msypes commented@RGronski:
Sorry. The correct function name is
hook_update_N. (I corrected it in my original post.) See https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Extension...In short, I put such a function in a custom module's .install file, and ran
drush updb. (I happen to have a custom module that I use for deployments, so it made sense to put it there.) You could put the code into a temporary Controller method and hit the URL with a browser, or anything else that gets that line of code to run.Comment #7
RGonski commented@mstypes
I have attempted to do this but it is currently beyond my skillset although I am trying to get that up to speed with this.
Is there anyway you might be able to help me achieve this? Could you give me the module or the .install file with the hook and the code embedded?
I would be very grateful for any assistance. This issue is causing grief for me and the website. :{{
Thank you
Comment #8
msypes commented@RGonski: It's a custom module specifically for my website idiosyncrasies.
There are plenty of resources online on how to create a module for Drupal v8 or v9, so I won't go into that.
Create a basic module,; it doesn't need to have anything beyond the minimum requirements, or use one you have already.
If what I wrote seems very heady, here's an easier path to follow, because again, there's plenty of online tutorials on how to create a custom route and Controller.
Your custom module needs, temporarily, this information:
my_module.routing.yml:
my_module.temp: path: /temp defaults: _controller: Drupal\my_module\Controller\MyModuleController:temp requirements: _permission: 'access content'MyModuleController:
With the module created and enabled, clear the caches, so that the route gets registered. Then point a browser at yourwebsite.com/temp
You'll get a blank screen or error message, but the code will have executed, fixing your issue.
Once you've verified that, you can/should delete the route and the Controller method.