After upgrading Drupal commerce kickstart to 7.38 there are database updates to be completed. Once deal with Commerce_discount and fails to update every time with the following message:

DatabaseSchemaObjectExistsException: Table field_data_discount_usage_per_person already exists. in DatabaseSchema->createTable() (line 660 of [localpath]/public/includes/database/schema.inc).

These two updates are pending:

7109 - Check for wrong discount values, before form validation was introduced. @see https:www.drupal.orgnode2468159#comment-10100064
7110 - Enable and update usage and date sub-modules into discount core.

When repeating the process the update 7110 seems to cause the problem:

Update 7109 finished. Please check all your percentage based discount settings for correct values after this update!Number of percentage values [ok]
in table "field_data_commerce_percentage" who were updated as a result: 0
Performed update: commerce_discount_update_7109

Table field_data_discount_usage_per_person already exists. [error]
Performed update: commerce_discount_update_7110

So, potential problems are:
- table exists and has data so it can't be modified
- table exists with corrupted data update fails
- table exists but update tries to create it again.

How can we contribute to fix this. Given the various recent security updates and subsequent commerce-kickstart updates and failures make this more difficult than I imagined it.

Comments

el_reverend created an issue. See original summary.

el_reverend’s picture

I have tried running the update on revert of a live site again, this time with deleting the offending table (it had no rows in it): but the same problem occurs:

 Commerce_discount  7110  Enable and update usage and date sub-modules into discount core.
Do you wish to run all pending updates? (y/n): y
Table field_revision_discount_usage_per_person already exists.                                                                                   [error]
Performed update: commerce_discount_update_7110                                                                                                  [ok]
exception 'DatabaseSchemaObjectExistsException' with message 'Table field_data_discount_usage_per_person already exists.' in                     [error]
/Users/sebastian/development/horsedreamimporters.com/public/includes/database/schema.inc:660
Stack trace:
#0 .../public/includes/database/database.inc(2720):
DatabaseSchema->createTable('field_data_disc...', Array)
#1 .../public/modules/field/modules/field_sql_storage/field_sql_storage.module(269):
db_create_table('field_data_disc...', Array)
#2 [internal function]: field_sql_storage_field_storage_create_field(Array)
#3 .../public/includes/module.inc(922): call_user_func_array('field_sql_stora...', Array)
#4 .../public/modules/field/field.crud.inc(180): module_invoke('field_sql_stora...',
'field_storage_c...', Array)
#5 .../public/profiles/commerce_kickstart/modules/contrib/commerce_discount/commerce_discount.install(335):
field_create_field(Array)
#6 .../public/profiles/commerce_kickstart/modules/contrib/commerce_discount/commerce_discount.module(242):
commerce_discount_install_helper()
#7 [internal function]: commerce_discount_flush_caches()
#8 .../public/includes/module.inc(951): call_user_func_array('commerce_discou...', Array)
#9 .../public/includes/common.inc(7626): module_invoke_all('flush_caches')
#10 phar:///usr/local/bin/drush/commands/core/drupal/cache.inc(99): drupal_flush_all_caches()
#11 phar:///usr/local/bin/drush/includes/drush.inc(724): drush_cache_clear_both()
#12 phar:///usr/local/bin/drush/includes/drush.inc(711): drush_call_user_func_array('drush_cache_cle...', Array)
#13 phar:///usr/local/bin/drush/commands/core/cache.drush.inc(144): drush_op('drush_cache_cle...')
#14 [internal function]: drush_cache_command_clear('all')
#15 phar:///usr/local/bin/drush/includes/command.inc(366): call_user_func_array('drush_cache_com...', Array)
#16 phar:///usr/local/bin/drush/includes/command.inc(217): _drush_invoke_hooks(Array, Array)
#17 [internal function]: drush_command('all')
#18 phar:///usr/local/bin/drush/includes/command.inc(185): call_user_func_array('drush_command', Array)
#19 phar:///usr/local/bin/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#20 phar:///usr/local/bin/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#21 phar:///usr/local/bin/drush/includes/startup.inc(321): drush_main()
#22 phar:///usr/local/bin/drush/drush(114): drush_startup(Array)
#23 /usr/local/bin/drush(10): require('phar:///usr/loc...')
#24 {main}
Finished performing updates.  
troseman’s picture

same issue here. also tried dropping table before update and same result.

giuseppe.minnella’s picture

Same issue here too.

Btw, one time easy workaround (not sure about side effects):
In
/profiles/commerce_kickstart/modules/contrib/commerce_discount/commerce_discount.install:188
set
$fields = field_read_fields(array(), array('include_inactive' => TRUE));
to
$fields = field_read_fields(array(), array('include_inactive' => FALSE));
run the update then bring it back to TRUE.

troseman’s picture

using Schema module saw that the field_data_discount_usage_* tables are unknown.
So deleted them:

drop table field_data_discount_usage_limit;
drop table field_data_discount_usage_per_person;
drop table field_revision_discount_usage_limit;
drop table field_revision_discount_usage_per_person;

re-ran drush dl commerce_kickstart (not sure if needed), then drush updatedb -y
succeeded with no errors.

candelas’s picture

Hello
I believe that this should be in the discount module. I change it and if you don't think is it correct, change it again :)

candelas’s picture

Project: Commerce Kickstart » Commerce Discount
Version: 7.x-2.38 » 7.x-1.x-dev