I am new to Drupal, and I am trying to write a module with an .install file which will create a database table. The table isn't being created (as seen from the error codes when I try to access it. It also doesn't show up in the Schema module listing) and I don't know what I did wrong. Can someone see if they can find the error?
This is the code:
function email_form_schema() {
$schema['subscription_info'] = array(
'description' => t('The base table for nodes.'),
'fields' => array(
'first' => array(
'description' => t('The first name'),
'type' => 'varchar',
'not null' => TRUE,
'default' => '',
),
'last' => array(
'description' => t('The last name'),
'type' => 'varchar',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => '',
),
'email' => array(
'description' => t('The email address'),
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => ''
),
'phone' => array(
'description' => t('The phone number.'),
'type' => 'varchar',
'length' => 10,
'not null' => TRUE,
'default' => '',
)
),
'primary key' => array('email'),
);
return $schema;
}
function email_form_install() {
// Create my tables.
drupal_install_schema('email_form');
}
function email_form_uninstall() {
// Drop my tables.
drupal_uninstall_schema('email_form');
}
Here's the error when I try to access it:
user warning: Table 'drupal620x120318224310.subscription_info' doesn't exist query: INSERT INTO subscription_info (first, last, email, phone) VALUES ('','','','') in C:\EasyPHP-5.3.8.1\modules\drupal620x120318224310\sites\all\modules\email_form\email_form.module on line 123.
I was missing the return $schema;
line (which I modified above), but it still doesn't work. In the schema module it lists the "subscription_info" table as missing. What does this mean?