Problem/Motivation
getting
$ drush pmu contact_storage
The following extensions will be uninstalled: contact_storage
Do you really want to continue? (y/n): y
PDOException: SQLSTATE[HY000]: General error: 1 no such column: id in /srv/core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php:82 [error]
Stack trace:
#0 /srv/core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php(82): PDO->prepare('SELECT 1 AS exp...')
#1 /srv/core/lib/Drupal/Core/Database/StatementPrefetch.php(158): Drupal\Core\Database\Driver\sqlite\Statement->getStatement('SELECT 1 AS exp...', Array)
#2 /srv/core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php(90): Drupal\Core\Database\StatementPrefetch->execute(Array, Array)
#3 /srv/core/lib/Drupal/Core/Database/Connection.php(631): Drupal\Core\Database\Driver\sqlite\Statement->execute(Array, Array)
#4 /srv/core/lib/Drupal/Core/Database/Query/Select.php(510): Drupal\Core\Database\Connection->query('SELECT 1 AS exp...', Array, Array)
#5 /srv/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(1792): Drupal\Core\Database\Query\Select->execute()
#6 /srv/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorageSchema.php(637): Drupal\Core\Entity\Sql\SqlContentEntityStorage->countFieldData(Object(Drupal\Core\Field\BaseFieldDefinition),
true)
#7 /srv/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(1577):
Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema->onFieldStorageDefinitionDelete(Object(Drupal\Core\Field\BaseFieldDefinition))
#8 /srv/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(1593): Drupal\Core\Entity\Sql\SqlContentEntityStorage->Drupal\Core\Entity\Sql\{closure}()
#9 /srv/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php(1578): Drupal\Core\Entity\Sql\SqlContentEntityStorage->wrapSchemaException(Object(Closure))
#10 /srv/core/lib/Drupal/Core/Field/FieldStorageDefinitionListener.php(172):
Drupal\Core\Entity\Sql\SqlContentEntityStorage->onFieldStorageDefinitionDelete(Object(Drupal\Core\Field\BaseFieldDefinition))
#11 /srv/core/lib/Drupal/Core/Entity/EntityDefinitionUpdateManager.php(271):
Drupal\Core\Field\FieldStorageDefinitionListener->onFieldStorageDefinitionDelete(Object(Drupal\Core\Field\BaseFieldDefinition))
#12 /srv/core/lib/Drupal/Core/Extension/ModuleInstaller.php(432): Drupal\Core\Entity\EntityDefinitionUpdateManager->uninstallFieldStorageDefinition(Object(Drupal\Core\Field\BaseFieldDefinition))
#13 /srv/core/lib/Drupal/Core/ProxyClass/Extension/ModuleInstaller.php(91): Drupal\Core\Extension\ModuleInstaller->uninstall(Array, true)
#14 phar:///usr/bin/drush/commands/core/drupal/environment.inc(227): Drupal\Core\ProxyClass\Extension\ModuleInstaller->uninstall(Array)
#15 phar:///usr/bin/drush/commands/core/drupal/pm_8.inc(79): drush_module_uninstall(Array)
#16 phar:///usr/bin/drush/commands/pm/pm.drush.inc(1250): _drush_pm_uninstall(Array)
#17 phar:///usr/bin/drush/includes/command.inc(422): drush_pm_uninstall('contact_storage')
#18 phar:///usr/bin/drush/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
#19 phar:///usr/bin/drush/includes/command.inc(199): drush_command('contact_storage')
#20 phar:///usr/bin/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#21 phar:///usr/bin/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#22 phar:///usr/bin/drush/includes/startup.inc(465): drush_main()
#23 phar:///usr/bin/drush/includes/startup.inc(369): drush_run_main(false, '/', 'Phar detected. ...')
#24 phar:///usr/bin/drush/drush(114): drush_startup(Array)
#25 /usr/bin/drush(10): require('phar:///usr/bin...')
#26 {main}
Next Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[HY000]: General error: 1 no such column: id: SELECT 1 AS expression
FROM
{contact_message} t
WHERE id IS NOT NULL
LIMIT 1 OFFSET 0; Array
(
)
in /srv/core/lib/Drupal/Core/Database/Connection.php:692
Stack trace:
Proposed resolution
Implement proper contact_storage_uninstall() hook
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comments
Comment #2
andypostGuess
contact_form(config entity) will server update themselfComment #3
andypostAfter module uninstalled it's fields and message table still live and never purged
Comment #4
andypostAfter uninstall/install/uninstall table and field tables remains unchanged but empty
Comment #5
andypostComment #6
andypostComment #9
vacho commentedMessage that appear when you try uninstall the module by GUI:
Drupal\Core\Entity\EntityStorageException: Exception thrown while performing a schema update. SQLSTATE[42S22]: Column not found: 1054 Unknown column 'entity_table.id' in 'field list': INSERT INTO {field_deleted_data_38d3088921} (bundle, entity_id, revision_id, langcode, created_value, deleted, delta) SELECT entity_table.contact_form AS bundle, entity_table.id AS entity_id, entity_table.id AS revision_id, entity_table.langcode AS langcode, entity_table.created AS created_value, :deleted AS deleted, :delta AS delta FROM {contact_message} entity_table WHERE entity_table.created IS NOT NULL FOR UPDATE; Array ( [:deleted] => 1 [:delta] => 0 ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->wrapSchemaException() (line 1490 of /var/www/html/contribdrupal86/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
When the patch #15 is applied
By GUI:
Then this message doesn't appear and module is well uninstalled.
By Drush command:
#drush pmu contact_storage
Then this message doesn't appear and module is well uninstalled.
In both cases tables: contact_message, contact_message__field_* Are empty
Environment: Drupal 8.6.11, Drush 8, mysql 5.
Comment #10
andypostComment #11
andypostComment #12
vacho commentedThe patch works fine in all cases that I review except when the contact form have an "Options email" field. It is the reason why the test fail too.
I trace the bug to the core and report it. https://www.drupal.org/project/drupal/issues/3040031
Comment #13
pandaski commented#6
typo in patch
to
Comment #14
pandaski commentedComment #15
andypostComment #18
eelkeblokNote that #3028830: SQL error when uninstalling is trying to solve the same issue, I closed it as a duplicate, although I now realize the solution here is also a bit "hacky", with uninstalling and installing storage. Doesn't it mean there is an underlying issue, when Drupal is unable to cleanly uninstall the entity?
Comment #19
mlzr#15 works.
First I want to uninstall toe 'Contact Storage' module, and it won't uninstall. Even, the page /admin/modules/uninstall gives a WSOD.
After apply the patch the uninstall works fine.
thanks,
MZLR
Comment #20
vasiliyrepin commented#15 works.


But after uninstall and install (reinstall) some elements of this module disappears.
1. At admin/structure/contact disappears View Messages at Website feedback
2. At /admin/structure/contact/messages incorrect view list data.
Comment #21
gilbertdelyon commentedSame issue here.
D 9.3.15
PHP 8.0.19
Some months ago, Install Contact Storage for testing .
Today, I cannot uninstall properly .
Go to Admin > Modules > Uninstall : error (so, I cannot uninstall any other module)
What I did:
- Delete module folder
- Empty all cache tables in database
- And site works again!
Then:
- Reinstall contact storage. It works.
- send contact message
- go to admin > structure > Contact Forms > List
Incorrect view
Then:
Install contact storage in a fresh D 9.3.15 site without any other contrib or custom module. It Seems to work properly.
Could we have a incompatibility issue with another module or setting ?
Contact storage has not been updated since June 2020 (2 years ago). Not very promissing.
Comment #22
berdirThe referenced core issue was closed. This will need a step, either manual or automated to first delete all configurable fields, as shown in the test fail, before deleting the entity type itself. The simplenews module has a manual form that does that,.
Comment #23
silverham commentedRerolled against latest release 8.x-1.3.
Comment #24
ultimikeThe patch in 23 works for me as well.
-mike
Comment #25
roybrockington commented#23 for the win on Drupal 9.5.9, at last!
Comment #26
chike#23 is working for me on Drupal 10.2.0.
Comment #27
liliplanet commentedHi! Had contact storage with fields installed.
Uninstalled contact_storage, now get error: The following table(s) do not have a primary key: contact_message.
Patched as per #23, installed, un-installed, error is still there.
I removed all contact_message fields from my database, error is gone, hope it does not cause issues down the line.
Comment #28
johnpicozziLooks like the patch in #23 doesn't apply cleanly to 8.x-1.5