D7: DatabaseSchemaObjectExistsException: Table quant_queue already exists.

Created on 19 July 2023, almost 2 years ago

Problem/Motivation

Database error when uninstalling and reinstalling the quant module.

Steps to reproduce

Kristens-MacBook-Pro:quantcdn kristenpol$ ddev drush pm:disable quant -y
The following extensions will be disabled: quant
Do you really want to continue? (y/n): y
quant was disabled successfully.                                                                                                                                        [ok]
Kristens-MacBook-Pro:quantcdn kristenpol$ ddev drush pm:uninstall quant -y
quant is already uninstalled.                                                                                                                                           [ok]
There were no modules that could be uninstalled.                                                                                                                        [ok]
Kristens-MacBook-Pro:quantcdn kristenpol$ ddev drush pm:enable quant -y
The following extensions will be enabled: quant
Do you really want to continue? (y/n): y
DatabaseSchemaObjectExistsException: Table quant_queue already exists. in /var/www/html/includes/database/schema.inc:731                                                [error]
Stack trace:
#0 /var/www/html/includes/database/database.inc(2837): DatabaseSchema->createTable('quant_queue', Array)
#1 /var/www/html/includes/common.inc(7269): db_create_table('quant_queue', Array)
#2 /var/www/html/includes/module.inc(484): drupal_install_schema('quant')
#3 phar:///usr/local/bin/drush8/commands/core/drupal/environment_7.inc(147): module_enable(Array)
#4 phar:///usr/local/bin/drush8/commands/pm/pm.drush.inc(1195): drush_module_enable(Array)
#5 phar:///usr/local/bin/drush8/includes/command.inc(422): drush_pm_enable('quant')
#6 phar:///usr/local/bin/drush8/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
#7 phar:///usr/local/bin/drush8/includes/command.inc(199): drush_command('quant')
#8 phar:///usr/local/bin/drush8/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#9 phar:///usr/local/bin/drush8/includes/preflight.inc(67): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#10 phar:///usr/local/bin/drush8/includes/startup.inc(465): drush_main()
#11 phar:///usr/local/bin/drush8/includes/startup.inc(369): drush_run_main(false, '/', 'Phar detected. ...')
#12 phar:///usr/local/bin/drush8/drush(114): drush_startup(Array)
#13 /usr/local/bin/drush8(10): require('phar:///usr/loc...')
#14 {main}
Failed to run drush pm:enable quant -y: exit status 1

Proposed resolution

Check if the database exists first before creating in the update hook.

Remaining tasks

  • Update code
  • Review and test
  • Commit :)

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States Kristen Pol Santa Cruz, CA, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024