Why is my table not automatically created at the time of custom module install? I am writing a custom module for Drupal 7. For the table creation I have created the .install file, but the table is not getting created automatically, when the module is installed. I have already uninstalled and reinstalled the module many times. All the times I do it, I get the following error:


  Base table or view not found: 1146 Table 'drupal.drupalform' doesn't exist


This is the code in the drupalform.install file.

function drupalform_schema() {
    $schema = array();
    $schema['drupalform'] = array(
        'description' =&gt; t('A table for holding the drupalform data!'),
        'fields' =&gt; array(
            'id' =&gt; array(
                'description' =&gt; t('Auto increment of the ID'),
                'type' =&gt; 'serial',
                'unsigned' =&gt; TRUE,
                'not null' =&gt; TRUE,
            ),
            'name' =&gt; array(
                'description' =&gt; t('Person\'s first name.'),
                'type' =&gt; 'varchar',
                'length' =&gt; 64,
                'not null' =&gt; TRUE,
            ),
            'last_name' =&gt; array(
                'description' =&gt; t('Person\'s last name.'),
                'type' =&gt; 'varchar',
                'length' =&gt; 64,
                'not null' =&gt; TRUE,
            ),
            'email' =&gt; array(
                'description' =&gt; t('Person\'s email'),
                'type' =&gt; 'varchar',
                'length' =&gt; 64,
                'not null' =&gt; TRUE
            ),
        ),
        'primary key' =&gt; array('id'),
    );
    return $schema;
}

function drupalform_install() {
    drupal_install_schema('drupalform');
}

function drupalform_uninstall() {
    drupal_uninstall_schema('drupalform');
}
The following line is not correct.

'primary_key' =&gt; array('id'),


Replace 'primary_key' with 'primary key'.

In Drupal 7 you do not need to call drupal_install_schema() nor drupal_uninstall_schema() for the database tables your module uses.

You can just declare the functions.

function drupalform_install() {}

function drupalform_uninstall() {}


Just update the code, uninstall the module, and re-install it.