[support] schema API -- why isn't my table being created?

Roy Smith roy at panix.com
Sat Aug 23 12:42:48 UTC 2008


Environment:

Drupal 6.3
MySQL 5.0.51b
PHP 5.2.6
schema-6.x-1.3

I'm trying to use the schema API, but can't get it to create my table  
in the database.  The module I'm developing is called "regatta".  This  
is a new module from scratch, not an upgrade.  I've created a  
regatta.install file (included below).

When I go to /admin/build/schema, it says that the boat table in the  
regatta module is missing.  There are 46 Match (all the normal core  
tables), zero Mismatch, and zero Extra.  Under /admin/build/schema/ 
describe, it lists "boat (regatta module)", and describes it correctly.

I've gone through several cycles of enabling and disabling regatta,  
and ran update.php.  Any ideas what I'm doing wrong?

<?php     // -*- mode: php; -*-

function regatta_schema() {
     $schema['boat'] = array(
         'description' => t('A boat'),
         'fields' => array(
             'id' => array(
                 'description' => t('The primary identifier for a  
boat.'),
                 'type' => 'serial',
                 'unsigned' => TRUE,
                 'not null' => TRUE
                 ),
             'sail_number' => array(
                 'description' => t('Sail number, optionally including  
country id'),
                 'type' => 'varchar',
                 'not null' => TRUE,
                 'length' => 10,
                 'default' => ''
                 ),
             'boat_name' => array(
                 'description' => t('Boat name'),
                 'type' => 'varchar',
                 'not null' => TRUE,
                 'length' => 24,
                 'default' => ''
                 ),
             'skipper_name' => array(
                 'description' => t('Skipper name'),
                 'type' => 'varchar',
                 'not null' => TRUE,
                 'length' => 24,
                 'default' => ''
                 ),
             ),
         'primary key' => array('id'),
         );
     return $schema;
}

function regatta_install() {
     drupal_install_schema('regatta');
}

function regatta_uninstall() {
     drupal_uninstall_schema('regatta');
}



----------------
Roy Smith
roy at panix.com






More information about the support mailing list