Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
So I was dealing with a complicated multisite and every time I installed a module to the default site, if I wasn't sharing the table, it of course didn't create tables for the other sites. So I did up a function to fix (create) missing tables. Also good for those rare cases when a table goes missing or just isn't created for some reason. It won't work for missing tables that interfere with bootstrap.
Command name: schema-fix-missing.
Comment | File | Size | Author |
---|---|---|---|
#7 | fix_missing_tables-2571659-7.patch | 4.76 KB | NickDickinsonWilde |
Comments
Comment #2
NickDickinsonWildeComment #4
NickDickinsonWildeoops... missed semi-colon in the help block I just added for upload.
Comment #5
NickDickinsonWildeComment #7
NickDickinsonWildeargh. reuploaded the same patch. Here's the right one.
Comment #8
brockfanning CreditAttribution: brockfanning commentedI just gave this a shot and it fixed my problem, thanks!
I did get a lot of warning, but it seems like they might be caused by another module (date module in my case). There seemed to be several for each date field we have on the site, and they were similar to this:
Probably unrelated to this patch, but just in case it helps. Again, the drush command worked great to create the missing table, and thanks again.
Comment #9
NickDickinsonWildeyes that is unrelated (although it may be exposed by this feature - but I believe from your description that it is also exposed in the standard schema functions)
Comment #10
joachim CreditAttribution: joachim as a volunteer commentedThanks for sharing your code!
Though see #935192: Automatic table schema repair button, which suggests that this isn't a good idea in general.
Comment #11
NickDickinsonWildeIssue #935192: Automatic table schema repair button isn't *quite* the same. Similar certainly. Been a *long* time so I don't remember all ramification but this was specifically for installing new modules on a multi-site; for any updates, you'd have to run updb/update.php per site but those won't work if the table isn't created first (which they won't in some circumstances). So depending on the situation, this is useful/limited risk but doesn't do updates.