When trying to create a table that already exists but is empty, recreate the table rather than throwing a DatabaseSchemaObjectExistsException

Created on 27 April 2012, over 12 years ago
Updated 30 March 2023, over 1 year ago

Why do we have this exception? (and in general why does D7 have so much worse handling of things like this??)

the error comes when a user tries to install a module which was previously installed and the .instal chokes simply because the table was already there.. and worse, it kills the process of enabling all the other modules that were trying to be enabled.

pretty sure in D6 we'd just skip this.. why does everything in D7 cause a stupid exception and just bail with a stupid message: "The website encountered an unexpected error. Please try again later. " really? try again later? why? is this magically going to fix itself?

what are we trying to avoid here?

- could the existing tables possibly be of an old design and therefore we would need to run updates on them? but can't db code see this and run the updates; most likely the system table entry is still there so we do know what version of schema exists?

- are we trying to force module designers to write code in all .installs to first check if tables exist and then handle this in the .install file? why would we want to replicate this code 200 times on a project?? why not have db code handle this?

really tired of seeing these exceptions all the time for no apparently useful reason.

Feature request
Status

Needs work

Version

10.1

Component
Database 

Last updated 1 day ago

  • Maintained by
  • 🇳🇱Netherlands @daffie
Created by

🇨🇦Canada liquidcms

Live updates comments and jobs are added and updated live.
  • Needs backport to D7

    After being applied to the 8.x branch, it should be considered for backport to the 7.x branch. Note: This tag should generally remain even after the backport has been written, approved, and committed.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇩🇪Germany stmh

    Hi, we are using the patch from #120 and it introduces a lot of problems when you have more than one PHP workers, as the function is not atomic anymore. This might work in a single-threaded install but will fail with hard to debug concurrency issues when called by code on every request. The purge module for example tries to create a table if it does not exist prior which leads to a never ending series of table creation and -dropping as one function call form Worker A is intertwined with a function call from Worker B.

    This happens under heavy load only, but still the offending code should be guarded by a lock.

  • 🇧🇬Bulgaria vuil Bulgaria 🇧🇬 🇪🇺 🌍
Production build 0.71.5 2024