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 559 forks source link

[generate:entity:content] in drupal 9 does not create entity table #4286

Open stef-van-looveren opened 3 years ago

stef-van-looveren commented 3 years ago

Problem/Motivation

Generating a content entity does not create entity table.

How to reproduce

bash-5.0$ drupal generate:entity:content

 // Welcome to the Drupal Content Entity generator
 Enter the module name [admin_toolbar]:
 > bid_offer

 Enter the class of your new content entity [DefaultEntity]:
 > Offer

 Enter the machine name of your new content entity [offer]:
 >

 Enter the label of your new content entity [Offer]:
 >

 Enter the base-path for the content entity routes [/admin/structure]:
 >

 Do you want this (content) entity to have bundles? (yes/no) [no]:
 >

 Is your entity translatable? (yes/no) [yes]:
 > no

 Is your entity revisionable? (yes/no) [yes]:
 >

 Do you want this (content) entity to have forms? (yes/no) [yes]:
 >

 Do you want this (content) entity to have an owner? (yes/no) [yes]:
 >

Generated or updated files
 Generation path: /var/www/html/web
 1 - modules/custom/bid_offer/bid_offer.permissions.yml
 2 - modules/custom/bid_offer/src/OfferAccessControlHandler.php
 3 - modules/custom/bid_offer/src/Entity/OfferInterface.php
 4 - modules/custom/bid_offer/src/Entity/Offer.php
 5 - modules/custom/bid_offer/src/Entity/OfferViewsData.php
 6 - modules/custom/bid_offer/src/OfferListBuilder.php
 7 - modules/custom/bid_offer/src/OfferHtmlRouteProvider.php
 8 - modules/custom/bid_offer/bid_offer.links.menu.yml
 9 - modules/custom/bid_offer/bid_offer.links.task.yml
 10 - modules/custom/bid_offer/bid_offer.links.action.yml
 11 - modules/custom/bid_offer/src/Form/OfferSettingsForm.php
 12 - modules/custom/bid_offer/src/Form/OfferForm.php
 13 - modules/custom/bid_offer/src/Form/OfferDeleteForm.php
 14 - modules/custom/bid_offer/templates/offer.html.twig
 15 - modules/custom/bid_offer/offer.page.inc
 16 - modules/custom/bid_offer/src/Form/OfferRevisionDeleteForm.php
 17 - modules/custom/bid_offer/src/Form/OfferRevisionRevertForm.php
 18 - modules/custom/bid_offer/src/Controller/OfferController.php
 19 - modules/custom/bid_offer/src/OfferStorage.php
 20 - modules/custom/bid_offer/src/OfferStorageInterface.php

 Generated lines: 1434

The error

When i proceed to /admin/structure/offer: Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'x__x.offer' doesn't exist: SELECT COUNT(*) AS "expression" FROM (SELECT 1 AS "expression" FROM {offer} "base_table") "subquery"; Array ( ) in Drupal\Core\Entity\EntityListBuilder->getEntityIds() (line 104 of core/lib/Drupal/Core/Entity/EntityListBuilder.php).

lkc-nvl-stf commented 3 years ago

If any one is struggling with this issue, it is because the module was enabled before the creation of the entity, resulting in the skipping of any table creation.

Solution: Use this module: https://www.drupal.org/project/devel_entity_updates

and run "drush entup"

aqala commented 1 year ago

Thanks, works for me

UttamKarmakar007 commented 1 year ago

Thanks works for me too

nmeegama commented 10 months ago

Thanks a lot a head scratcher really

capysara commented 8 months ago

I had the same problem, and the comments in this issue helped me get to the root of it. In my case, I answered "No" (which is the default provided response) to "The entity type has bundle?" It didn't create the schema.info.yml file, which means it didn't create the entity. When I answered "Yes", I had no issues.

Thanks!