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

Roy Smith roy at panix.com
Sun Aug 24 14:22:41 UTC 2008


More on this...

I wrote a regatta_update_1() function and put it in my regatta.install  
file.  I then disabled and re-enabled the regatta module.  This had no  
effect.

I then decided to upgrade to core 6.4.  Lo and behold, after I was  
done with the 6.4 upgrade, my boat table was there!  Obviously, there  
is some event which triggers running the table creation which I  
haven't figured out yet.


On Aug 23, 2008, at 8:42 AM, Roy Smith wrote:

> 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
>
>
>
>
> -- 
> [ Drupal support list | http://lists.drupal.org/ ]
>

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






More information about the support mailing list