By abruzzi on
I trying to learn to write modules that have their own data tables. Initially the module had hard coded values, I disabled the module added the following .install file, and reenabled the module, but it doesn't seem to create the table. Am I misunderstanding the behavior of the system?
// set up tables for dac_appmenu
function dac_appmenu_install() {
drupal_install_schema('dac_appmenu');
}
function dac_appmenu_uninstall() {
drupal_uninstall_schema('dac_appmenu');
}
/**
* Implementation of hook_schemea
*/
function dac_appmenu_schema() {
$schema['dac_appmenu_apps'] = array(
'description' => t('Table to list applications'),
'fields' => array(
'dacappid' => array(
'description' => t('Primary key for this table'),
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE),
'dacappname' => array(
'description' => t('Human readable application name'),
'type' => 'varchar',
'length' => 120,
'not null' => TRUE,
'default' => ''),
'dacappurl' => array(
'description' => t('url or application'),
'type' => 'varchar',
'length' => 200,
'not null' => TRUE,
'default' => ''),
'dacappzone' => array(
'description' => t('security zone for application'),
'type' => 'varchar',
'length' => 30,
'not null' => TRUE,
'default' => '')
),
'primary key' => array('dacappid')
);
return $schema;
}
(in the actual file, the closing php tag is omitted.)
thanks,
Geof
Comments
You have to completely
You have to completely uninstall the module for the install hook to be run again. Just disabling the module doesn't uninstall your tables.
Or you could use hook_disable
Or you could use hook_disable if you don't want do uninstall everytime. Or use both :)
If I'm not mistaken
I was indeed mistaken. If I knew how to delete this comment I would.
Follow these steps
See http://drupal.org/node/323314#comment-3924410 for step by step instructions on how to add a .install file to a module that is already installed on your site.