Drupal Commerce Field Deletion Failure After Uninstall

  • Sharebar

    I thought i’d share with everyone a helpful solution to a nasty bug in drupal / drupal commerce

    Issue:

    You’re excited. A new drupal module version is released. You’re trying to upgrade and now you’re ridden with a fatal error.

    Problem:

    There’s a nasty bug in Drupal entity fields that is currently trying to be sorted out. When you upgrade you may be unable to fully upgrade because modules are unable to delete previous database fields. It’s best if you uninstall then reinstall particular modules. There’s no direct path to upgrading for some particular modules Dependant on the entity field system.

    At this moment of writing, when you upgrade a module there’s not a way to delete existing entity fields in the database. They’re currently working on this issue in drupal 7/8.

    Thus, when you upgrade modules there will be lots of zombie fields in your drupal database. So when you upgrade you’ll

    Solution:

    1. Backup your database.
    2. The only way of dealing with this issue is to manually delete all the database fields in drupal.
    3. Using a script remove the database fields: Commerce Clean up Script for versions alpha2-alpha4 (Use with lots of caution. I do not provide any warrantee for this script):

    Related Drupal.org Issue queues:
    Drupal Commerce uninstall field failure: http://drupal.org/node/858722
    Drupal Commerce Uninstall Instructions: http://drupal.org/node/858722#comment-4165896

    • http://www.bywombats.com Ryan Szrama

      Perhaps I don’t understand your post, but you should never be uninstalling and reinstalling Drupal Commerce when you update from one version to the next. Additionally, Commerce actually does have a workaround to delete its own fields when you uninstall modules, but there may be a related issue with respect to what it actually means to delete a field. The curious can refer to my comment further down in that linked thread where I fixed uninstallation in July:

      http://drupal.org/node/858722#comment-4727530

      If we ever change field data between releases, I’d just write direct SQL queries if API functions did not exist to make appropriate changes before I recommended someone uninstall and reinstall. However, if you did need to uninstall Commerce for some other reason, it should still work just fine if you follow the instructions at the bottom of this page:

      http://drupal.org/node/1007434

      Caveat emptor: in a test just now, I do see that certain modules may be uninstallable due to fields they define being used. It’ll never be a walk in the park, but you should also never have to take the walk on a normal update. : )