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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

NickWilde created an issue. See original summary.

NickDickinsonWilde’s picture

Issue summary: View changes
FileSize
4.76 KB

Status: Needs review » Needs work

The last submitted patch, 2: fix_missing_tables-2571659-2.patch, failed testing.

NickDickinsonWilde’s picture

FileSize
4.76 KB

oops... missed semi-colon in the help block I just added for upload.

NickDickinsonWilde’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 4: fix_missing_tables-2571659-4.patch, failed testing.

NickDickinsonWilde’s picture

Status: Needs work » Needs review
FileSize
4.76 KB

argh. reuploaded the same patch. Here's the right one.

brockfanning’s picture

I 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:

field_data_field_casedoc_date.field_casedoc_date_value: no  type for Schema type datetime:normal.                             [warning]
Field field_data_field_casedoc_date.field_casedoc_date_value: no Schema type for  type datetime.                              [warning]
field_revision_field_casedoc_date.field_casedoc_date_value: no  type for Schema type datetime:normal.                         [warning]
Field field_revision_field_casedoc_date.field_casedoc_date_value: no Schema type for  type datetime.                          [warning]

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.

NickDickinsonWilde’s picture

yes 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)

joachim’s picture

Thanks for sharing your code!

Though see #935192: Automatic table schema repair button, which suggests that this isn't a good idea in general.

NickDickinsonWilde’s picture

Issue #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.