Problem/Motivation

The module declares simple_favs_user and simple_favs_user_other in hook_schema(). Drupal creates tables declared by hook_schema() during module installation. The module then tries to create the same tables again in hook_install(), causing installation to fail with
"Table 'simple_favs_user' already exists."

Steps to reproduce

1. Install Drupal 11.4.
2. Add simple_favs under modules/contrib.
3. Run: drush en -y simple_favs

Proposed resolution

Remove the manual createTable() calls from hook_install(). Keep only the
non-schema install work there:

function simple_favs_install() {
  _simple_favs_import_translation('fr');
}
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

dkmishra created an issue. See original summary.

dkmishra’s picture

Assigned: dkmishra » Unassigned
Status: Active » Needs review
joseph.olstad’s picture

Status: Needs review » Needs work

Merge request is wrong. the install should first check to see if the tables already exist and put those two functions inside the condition where the tables do not exist.

Alternatively someone could put a hook uninstall to remove the tables during the uninstall however prefer adding the check to see if the tables do not exist yet.

dkmishra’s picture

Status: Needs work » Needs review

Thanks for the feedback, @joseph.olstad. Updated MR !8 — hook_install() now checks tableExists() before calling createTable() for both simple_favs_user and simple_favs_user_other, rather than removing the calls outright. This keeps the manual creation as a defensive fallback for any install path that doesn't go through the normal hook_schema() flow, while still fixing the "table already exists" fatal on the standard drush en install.

Tested locally with drush pm:uninstall simple_favs -y followed by drush en simple_favs -y — installs cleanly now.
Moving back to "Needs review."

joseph.olstad’s picture

Status: Needs review » Fixed

Thanks

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

joseph.olstad’s picture