The following function is contained in process_login.install as part of a custom module called process_login. The module works if I manually created the database table, but naturally I would like the table created automatically on install.

The function itself does not generate a schema error on installing the module. But neither does it create the database table process_login_register in the Drupal 7 MySQL database.

There are no other errors I can see, or problems reported by Site Report.

I have removed it completely and reinstalled numerous times. I have searched the web extensively, and consulted two books I have on Drupal development. I can't see anything wrong with this function (listed below).

NOTE: I have also tried defining 'id' as serial but get the same result (i.e. no table created).

I have run out of ideas. Does anybody know why this function isn't working?

function process_login_schema(){
  $schema['process_login_register'] = array(
        'description' => 'Register a specific computer with the system.',
        'fields' => array(
                'id' => array(
                    'description' => 'Primary identifier.',
                    'type' => 'int',
                    'unsigned' => TRUE,
                    'size' => 'normal',
                    'not null' => TRUE,
                    'default' => 0,
                'ip' => array(
                        'description' => "The user's IP address at registration.",
                        'type' => 'varchar',
                        'length' => 32,
                        'not null' => TRUE,
                        'default' => '',
                'user_agent' => array(
                        'description' => "The user's browser user agent string at registration.",
                        'type' => 'varchar',
                        'length' => 255,
                        'not null' => TRUE,
                        'default' => '',
        'primary key' => array('id'),
  return $schema;
  • What Drupal version are you using?
    – googletorp
    Commented Jun 18, 2012 at 15:27
  • 3
    Have you actually uninstalled and reinstalled (not just disabled and re-enabled) the module since writing the function?
    – Clive
    Commented Jun 18, 2012 at 15:31
  • Drupal 6 requires to call drupal_install_schema() in hook_install. In Drupal 7 it is recommended not to call it explicitly. Commented Jun 18, 2012 at 15:57
  • Answers to above: Drupal 7. Yes. I'm using Drupal 7 so not calling drupal_install_schema().
    – user8109
    Commented Jun 18, 2012 at 16:03
  • 1
    @user8109 Enabling/disabling and installing/uninstalling are two completely different things in modules. Enabling a module (checking it in the modules page and pressing 'Submit') will only enable a module, and invoke hook_enable(). Installing a module can only be done after it's been uninstalled (using the uninstall tab or devel/reinstall), after which all tables created by the module are deleted. When you then install the module, hook_install() is run as you'd expect
    – Clive
    Commented Jun 18, 2012 at 16:37

2 Answers 2


Use drush dre -y [module] which disables, uninstalls and then re-enables the module. The -y flag makes it even faster, avoiding you have to press y and enter three times.


Only if you uninstall a module, and subsequently re-install it, the database tables it uses and declares with hook_schema() are re-created.

To uninstall a module, you need to:

  • Uncheck the checkbox shown for the module


  • Click on Save configuration


  • Click on the :Uninstall_ tab

  • Click on the check box to the left of the module name
  • Click on the Uninstall button


  • On the next page, confirm you want to uninstall that module by clicking on the Uninstall button


As alternative, if you have installed Drush, you can use the following commands.

drush pm-disable $module
drush pm-install $module
drush en $module

Replace $module with the short name of the module, between apices, and without the .module extension.

What you have done is disabling the module, and then re-enabling it. Even if you deleted the directory containing the module, for Drupal what you have done is just disabling, and then re-enabling it.

  • Is it possible to do this using drupal_install_schema and drupal_uninstall_schema .... drupal.org/node/876250
    – Hitesh
    Commented Sep 2, 2014 at 5:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.