1

I've uninstalled the Commerce Coupon 7.x-2.0-beta3 through the admin ui and removed the corresponding folder from the sites/all/modules directory. Now when I install the previous version of Commerce Coupon 7.x-1.0-beta7 I get hit with the error.

DatabaseSchemaObjectExistsException:
 Table <em class="placeholder">commerce_coupon</em> already exists.

When I look at the Database in phpMyAdmin I see the the following references.

  • commerce_coupon
  • commerce_coupon_type
  • field_data_commerce_coupon_order_reference
  • field_data_commerce_coupon_reference
  • field_revision_commerce_coupon_order_reference
  • field_revision_commerce_coupon_reference

I am not very familiar working with tables through SQL. Is there a basic procedure or query that is commonly used for deleting all references to a particular Drupal module?

6
  • Are you sure you actually uninstalled it and not just disabled it?
    – Clive
    Commented Jun 20, 2014 at 15:20
  • Yes through admin/modules/uninstall
    – dimmech
    Commented Jun 20, 2014 at 15:22
  • Hmm that's odd, you shouldn't have been able to uninstall it: if a module defines field types that are in use it can't be uninstalled. Is there any more to this or did you literally install commerce coupon, play with it, decide it wasn't for you, uninstall it, and then this happened?
    – Clive
    Commented Jun 20, 2014 at 15:25
  • Come to think of it you can't even disable a module with field types in use, so it's very strange you were able to
    – Clive
    Commented Jun 20, 2014 at 15:26
  • I've inherited the site from someone else so there is no telling what was done previously. However I came across this post drupal.org/node/1551132 and it seems that this pops up here and there with no real explanation for how it happens or how to fix it.
    – dimmech
    Commented Jun 20, 2014 at 15:29

2 Answers 2

1

There's no single procedure for manually removing a module, it kind of depends on what has been installed, where it's been installed and how it's been used.

For commerce coupon the basics are pretty simple:

  • Remove commerce_coupon and commerce_coupon_type
  • Remove the 4 field tables.
  • DELETE FROM field_config_instance WHERE field_name IN ('field_data_commerce_coupon_order_reference', 'field_data_commerce_coupon_reference')
  • DELETE FROM field_config WHERE field_name IN ('field_data_commerce_coupon_order_reference', 'field_data_commerce_coupon_reference')
  • Flush the caches

From there it gets a bit trickier. Depending on how the module's been used you may have references to coupons in the commerce_line_item table, with relationships back to their order in field_data_commerce_line_items (and the corresponding revision table). Those should also be removed to prevent errors when line items are loaded.

As you mentioned in the comments there may also be related rules (and potentially views as well), hunting down and deleting those manually might be the easiest thing to do.

4
  • I followed your direction and everything on the surface looks ok. I've also cleared cache and run cron. When I install the module however, it apears in the module list already enabled and now shows up in admin/modules/uninstall to be uninstalled however the uninstall fails because its looking for a table thats not there anymore.
    – dimmech
    Commented Jun 20, 2014 at 18:57
  • I don't know what's going on there then, sounds like a really unhappy install. But it might be easy to fix - if the module's actually not installed, try simply deleting the row for commerce_coupon in the system table. Then clear the caches (forcibly truncate at least cache and cache_bootstrap, preferably all of them) and you should be back to normal
    – Clive
    Commented Jun 20, 2014 at 19:14
  • Well I can cleanly install and uninstall the offending modules now. Following the trail to the next item I tried to create a coupon and found the rabbi hole. PDOException: SQLSTATE[42S02]: Which led to this thread. drupal.org/node/1604918
    – dimmech
    Commented Jun 20, 2014 at 20:38
  • I'll now follow the directions there and post when I've either come to a dead end or a fix. I'm marking this as the answer to my original question an will link or comment here to any further success with my new problem. Thank you Clive!
    – dimmech
    Commented Jun 20, 2014 at 20:44
1

Using the help provided by @Clive this was the procedure that enabled me to install the Commerce Coupon modules that I wanted to use without error.

Clear all caches Run Cron

  1. Select all cache tables in phpMyAdmin then go bottom of page and under "With selected" dropdown chose empty.

  2. Use phpMyAdmin to search for "%commerce_coupon%" then delete the found entries which in my case were:

    • 1 match in commerce_checkout_pane
    • 1 match in commerce_line_item
    • 3 matches in field_config
    • 14 matches in field_config_instance
    • 1 field_data_commerce_coupon_reference
    • 1 match in field_data_commerce_order_total
    • 1 match in field_data_commerce_total
    • 1 match in field_data_commerce_unit_price
    • 1 match in field_revision_commerce_coupon_reference
    • 1 match in field_revision_commerce_order_total
    • 1 match in field_revision_commerce_total
    • 1 match in field_revision_commerce_unit_price
    • 7 matches in system
    • 4 matches in variable
  3. Drop the following tables if they exist

    • commerce_coupon
    • commerce_coupon_type
    • field_data_commerce_coupon_order_reference
    • field_data_commerce_coupon_reference
    • field_revision_commerce_coupon_order_reference
    • field_revision_commerce_coupon_reference
  4. Install latest Commerce Coupon Dev version of 7.x-1 branch

  5. Install Commerce Coupon Percentage

  6. Install Commerce Coupon Fixed Amount

run update.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.