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;
}
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♦ Jun 18 '12 at 16:37