I'm trying to create a module for Drupal 7 and I need to create 3 tables and populate it. But first i need to create it.

In the file mymodule.install I have got

function mymodule_install() {


function mymodule_uninstall() {


function myodule_schema() {
  $schema['mymodule_table'] = array(
    'description' => t('First table'),
    'fields' => array(
      'id' => array(
        'description' => t('My unique identifier'),
        'type' => 'int',
        'unsigned' => true,
        'not null' => true,
      'list' => array(
        'description' => t('list'),
        'type' => 'varchar',
        'not null' => true,
    'primary key' => array('id'),
  return $schema;     

What am I doing wrong? Every time I test the module, I disable it -> uninstall -> Performance clear cache -> enable it.

  • 3
    If you have drush and devel installed you could use drush devel-reinstall mymodule to quickly reinstall your module
    – FLY
    May 17, 2013 at 9:23

2 Answers 2


You're missing the length property for the varchar column ('list'). length is required so the CREATE TABLE query will fail.

From the Schema API docs:

All parameters apart from 'type' are optional except that type 'numeric' columns must specify 'precision' and 'scale', and 'varchar' columns must specify 'length'.


myodule_schema has a typo. An m is missing after the y.

  • Thanks BetaRide, it was a transcription mistake. I give you one vote up because you have read my post and actually I really found a spelling mistake on the name of the function eh eh Jun 27, 2012 at 12:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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