Drupal Answers is a question and answer site for Drupal developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

function email_form_uninstall() {
  // Drop my tables.

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-\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?

share|improve this question
up vote 2 down vote accepted

If I had a penny for every time I've done this...

You've forgotten to return $schema from your email_form_schema() function.

You'll need to reinstall the module (not just disable then re-enable) for the changes to take effect.

There's also a problem with the "last" column. It's a "varchar" and you're using the "unsigned" property which isn't compatible with that type.

You also need to provide the "length" property for all of the "varchar" type columns, including "first" and "last".

share|improve this answer
Oops. You're right. But now (in the Schema Module) I now have the error: Tables in the [email_form] schema aren't present in the database, and I still can't access the table. What does this mean? – user1015214 Mar 28 '12 at 19:29
I remember this happening in Drupal 6, how are you reinstalling the module? If you're not already I'd install the Devel module then visit mysite.com/devel/reinstall. If memory serves selecting to reinstall the module at that path a couple of times will stop the errors and install the table correctly – Clive Mar 28 '12 at 19:46
I have been uninstalling it manually on the module page. I tried it your way and got the following: – user1015214 Mar 28 '12 at 19:56
@Clive I would add what you reported in your last comment as part of the answer, in that way, who reads your answer doesn't need to read 7 comments to find some relevant, and important information to know. – kiamlaluno Mar 28 '12 at 21:27
@Clive Whoops… Never mind. I mis-read it. – kiamlaluno Mar 29 '12 at 1:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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