hechoendrupal / drupal-console

The Drupal CLI. A tool to generate boilerplate code, interact with and debug Drupal.
http://drupalconsole.com
GNU General Public License v2.0
940 stars 560 forks source link

Using generate:entity:content breaks site after installing the module. #4065

Closed gonssal closed 4 years ago

gonssal commented 5 years ago

[generate:entity:content] Site breaks after module installation

Problem/Motivation

generate:entity:content breaks site after the module installation.

How to reproduce

Generate a module and then use generate:entity:content on it. Install the module afterwards.

After installation, I get the following error:

[ERROR] SQLSTATE[42S02]: Base table or view not found: 1146 Table 'drupal8.animal' doesn't exist: SELECT base_table.vid
         AS vid, base_table.id AS id                                                                                    
         FROM                                                                                                           
         {animal} base_table                                                                                            
         GROUP BY base_table.vid, base_table.id                                                                         
         LIMIT 1 OFFSET 0; Array                                                                                        
         (                                                                                                              
         )

The created entity name is "animal" of course.

The error also happens when trying to uninstall the module, even with Drupal Console or Drush, so basically the site is broken.

Also I tried using drupal update:entities as stated in Drupal's documentation, to no avail.

gonssal commented 5 years ago

Closing because after some digging it seems more like a core bug to me and I've given up on D8 for the project.

stephenplatz commented 5 years ago

This exact error is happening for me.

drush entup shows

ip_address entity type : 
The IP Address entity type needs to be installed.
ip_address_type entity type : 
The IP Address type entity type needs to be installed.

but after performing the updates, clearing the cache and running drush entup again, the same updates are needed.

drupal update:entity goes through the process with the normal feedback, but doesn't install the module either.

gonssal commented 5 years ago

So I stumbled upon this again in another project.

I haven't digged into it, but to me it seems that the issue is this change in core. This makes drush entup not work for <=8.7 and I bet drupal-console has the same problem. The latest versions of Drush already warn about this and don't run the entup command.

With the devel_entity_updates project, you can make the Drush command work again, but read the warnings, because the feature was removed for a reason.

For Drupal console, I think the only way is to wait for the devs to either implement what's in devel_entity_updates or just remove the drupal update:entities command and add a warning to the generate:entity:content saying that you have to implement the schema changes yourself.

Hope it helps someone.

Maybe the issue could be reopened if there's not one handling with this already.

enzolutions commented 4 years ago

Fixed with PR https://github.com/hechoendrupal/drupal-console/pull/4155 will be included in release 1.9.4