drupal-console icon indicating copy to clipboard operation
drupal-console copied to clipboard

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

Open stef-van-looveren opened this issue 3 years ago • 5 comments

Problem/Motivation

Generating a content entity does not create entity table.

How to reproduce

  • Drupal 9.0.7
  • Drupal console version 1.9.5
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).

stef-van-looveren avatar Nov 17 '20 13:11 stef-van-looveren

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"

lkc-nvl-stf avatar Feb 13 '21 19:02 lkc-nvl-stf

Thanks, works for me

aqala avatar Jun 11 '23 16:06 aqala

Thanks works for me too

UttamKarmakar007 avatar Sep 16 '23 20:09 UttamKarmakar007

Thanks a lot a head scratcher really

nmeegama avatar Nov 13 '23 02:11 nmeegama

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!

capysara avatar Jan 03 '24 15:01 capysara