Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
I have practically copied the custom module from Drupal Pro Development to the point where it is supposed to install a table for the module into the database on hook_install.
It doesn't create a new table.
I've search about and tried to install on hook_enable too, but nothing works.
I have dropped the DB.
Put in a fresh one.
Tried to install.... and the tables are not created.
So I have totally no clue why this isn't working.
I've zipped up the code and if someone can tell me what I have done wrong then that would be great.
Thanks,
Ben.
Comments
Comment #1
VM CreditAttribution: VM commentedThis belongs in the mdoule development forum as it's not a core issue.
Comment #2
aldrenalin CreditAttribution: aldrenalin commentedI had similar symptoms ... a simple install file that wouldn't create a table.
However, I got it to work by going into the Drupal system table and deleting the record for my module.
Then the next time that I enabled my module, Drupal freshly discovered it and ran the .install file to successfully create the table.
Summary. When you have a module already in use (and so it appears in the system table),
and *then* as a developer you create its .install file,
it doesn't look like a *new* installation to Drupal (since the module name was already in the system table), so hook_install never gets called.
Comment #3
ussher CreditAttribution: ussher commentedThanks aldrenalin,
This is exactly the bit of info that i needed. I couldn't understand why the schema would not install. There was no 'uninstall' because the .install file was not there when the module was first installed. all is well now. Thanks very much.