-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed: cache_entity_*
tables must be dropped before running update.php
when upgrading from Drupal 7.
#5340
Comments
Yes, my experience has been that if the site is already installed Backdrop creates these database tables. My D7 database did not have these tables. update.php apparently tries to create these tables but can't when they already exist. |
When #74 went in, the update hooks include lines like this:
But should probably have checked first to see if the table exists already (in the case of upgrades that already had the table):
Or:
|
Since these are cache tables, I think that it'd be safer to drop them and re-create them (the data they hold is by nature disposable & recreate-able anyway). Doing so would ensure that the tables are using the latest schema. |
One thing maybe worth to consider: actually, if doing it that way, there might exist additional db tables, that cause trouble - other than the cache tables. Although it's not recommended to install/enable modules in B prior to upgrading. Personally, I wouldn't recommend to just overwrite the database with the dump's contents, which means that pre-existing tables that are not overridden by the dump, are kept as-is. I'd suggest to actually either drop the B database and then import the D7 database (cleanly), or switch to a different one via the db credentials in settings.php. There still might be problems with config - for instance if the D7 site did not use the comments module, but B enables the module for default installs. So the comment config is around, but there are no db tables for it in the D7 dump. But that's out of scope of this issue. |
Yes, actually that makes sense that it may be because I ran the import multiple times and reloaded (but didn't empty first) the 'backdrop-ready' database each time. I was assuming it was because Entity Cache was active on the D7 site -- but I guess I don't know that I even verified that that was true in this case (update: I just checked and in this case Entity Cache was not active on the D7 site, but I think that is technically possible that EC would have created those tables in D7). |
@laryn you're, of course, right. Entity cache could be installed in D7, so in this case it's correct to drop and recreate the tables, to make sure, it's Backdrop's schema. |
Seemed like an easy one so created a PR backdrop/backdrop#3846 |
Code looks good 👍 |
Yup, the code change looks straight-forward to me too 👍🏼 @keiserjb do you have capacity/motivation to give this a go? ...if I get a chance, I'll re-watch the video and try to come up with minimal steps to reproduce this. |
Works for me without needing to drop the tables. |
Is that enough testing to warrant a "Works for Me"? |
I plan to also take a shot at it tomorrow:
I'll then try the above steps, but with a vanilla Backdrop + the changes from this PR. |
The site I did this with did not use the Entity Cache module. Under normal circumstances I would not try to upgrade a database after installing Backdrop. When making the video I wanted to try this in my cloud dev environment. It spins up the site as a vanilla install. To do everything in the cloud I needed to overwrite the database. I also did this upgrade a number of times by dropping all the tables in the database inside phpmyadmin and then importing anew. That took longer though. My normal workflow would be to do the upgrade locally with Lando and not install vanilla Backdrop first. Just import the database that I wanted to upgrade. That process would drop the database before importing and therefore not require manually dropping tables. |
I have just tested this on a vanilla Backdrop installation vs one patched with the changes in the PR. The db update errors are gone 👍🏼 (separate follow-up for the I've updated the issue summary with steps to reproduce while at it. |
Thanks @klonos for reporting and testing, and @herbdool for the fix. Thanks to @keiserjb and @indigoxela for input as well. I've merged backdrop/backdrop#3846 into 1.x and 1.20.x. |
cache_entity_*
tables must be dropped before running update.php
when upgrading from Drupal 7.
See: https://www.youtube.com/watch?v=U0RED0cZZwo&t=756s
The person running the update said that they have in the past run the update, and they have been getting errors if the following tables exist in the database:
cache_entity_comment
cache_entity_file
cache_entity_node
cache_entity_taxonomy_term
cache_entity_user
Their workaround has been to manually drop these tables. Can we do anything about that?
Steps to reproduce
$settings['update_free_access'] = FALSE;
toTRUE
/core/update.php
Actual result
After the updates have finished, the following error is shown:
In the db updates report section, the following update failures are shown:
user module
taxonomy module
comment module
node module
file module
Expected result
No errors.
The text was updated successfully, but these errors were encountered: