2

When I hit the Uninstall tab in the UI or try to uninstall a module with Drush I get the following errors:

Drush:

SQLSTATE[42S02]: Base table or view not found: 
1146 Table 'DATABASENAME.br_schedule' doesn't exist

Drupal Log:

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S02]: 
Base table or view not found: 
1146 Table 'DATABASENAME.br_schedule' doesn't exist: 
SELECT base_table.vid AS vid, 
base_table.id AS id FROM {br_schedule} 
base_table LIMIT 1 OFFSET 0; Array ( ) in 
Drupal\Core\Entity\EntityStorageBase->hasData() 
(line 552 of MYSITEPATH/core/lib/Drupal/Core/Entity/EntityStorageBase.php).

I have no idea what br_schedule is so I don't know how to rebuild that table. I have Businesses Rules installed but I see no br_schedule module.

2
  • It doesn’t have to be a module necessarily, a module can create as many tables as it needs to. An easy way to get out of this is to create a bare table using a database editor/interface called br_schedule then try to uninstall the module. This will get you around the error. The rest sounds like a bug for the Business rules module. – Kevin Feb 3 '19 at 17:25
  • 1
    br_schedule is the base table for the business_rules_schedule entity type. Perhaps the module was previously installed before the entity type existed in the current version. Maybe drush updb could solve the issue (it should run entup as well these days). – mradcliffe Feb 3 '19 at 18:15
2

Found the issue. My database updates are not happening. Ran updatedb:status with drush and I get:

file_entity                           8004        hook_update_n   Fix entity field mismatches on the file type field.
business_rules_schedule entity type               entity-update   The Schedule entity type needs to be installed.
file entity type                                  entity-update   The File type field needs to be updated.
node entity type                                  entity-update   The node.field_zipcode field needs to be updated.

"Fix entity field mismatches on the file type field." is failing so the "business_rules_schedule" update isn't happening.

1

I spun up a blank D8 with Business Rules installed and exported the br_schedule table and imported it into the effected site. Now I can uninstall modules.

0

Perhaps the easiest workaround as @kevin mentions would be to download adminer or use existing phpmyadmin if you have and create that table with no content running the following (or similar) SQL command

CREATE TABLE br_schedule (
    ID int
);

then try again to see if it can uninstall

NOTE: use with caution its not a bulletproof technique, I have used it a few times and was able to complete broken uninstalls on messed up databases but as mradcliffe mentions it might screw things up as well.

2
  • 1
    This might cause further errors because the table is provided by a content entity type. – mradcliffe Feb 3 '19 at 18:16
  • 1
    @mradcliffe perhaps you are right its a trial and error not to be tried on live site, I am not aware of what br_schedule is but the above technique has saved me a few times when I get in my hands a broken DB – GiorgosK Feb 3 '19 at 18:41
0

Just run "drush entity-updates" to create the entities before you run drush updb.

1
  • Drupal removed its automatic entity-updates API in 8.7. See https://www.drupal.org/node/3034742. . – augusto Apr 8 '20 at 5:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.