I am developing a small module and when I go to install it my .install (file) fails to create the table in the database. When I use the Schema tool, it shows Missing (1) and the detail states "Tables in the schema that are not present in the database."
If I then reinstall the module using devl's reinstall module, the table will get created. I have spent much time working on this error and I can repeatedly recreate it. I have broken down my .install code into smaller pieces and repeatedly recreated the file from scratch, all to no avail.
Has anyone every since a problem like this ? Is there any way to determine why the table is not getting created.?
Note: I can create and load other modules without this problem. I just can't see what is going wrong with this particular module.
I am running Drupal 6.5 and PHP 5.2.6. using XAMPP 1.6.8 running on Windows XP SP2.
Comments
why not post your .install
why not post your .install file together with your question ...?
Heres's the code.
<?php
// $Id$
/* @file
* ugcp module
*
*
* Implementation of hook_install().
*/
function ugcp_install() {
drupal_install_schema('ugcp');
}
function ugcp_uninstall() {
drupal_uninstall_schema('ugcp');
}
/**
* Implementation of hook_schema().
*/
function ugcp_schema() {
$schema['ugcp'] = array(
'description' => t("Stores data for nodes of type 'ugcp'."),
'fields' => array(
'nid' => array('description' => t("The ugcp's {node}.nid."),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'uid' => array(
'description' => t("The ugcp's {node}.uid."),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'created' => array(
'description' => t('A Unix timestamp indicating when the Proposal was created.'),
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'dept' => array(
'description' => t('Department or Program'),
'type' => 'varchar',
'length'=>50,
'not null' => TRUE,
'default' => '',
),
'mailstation' => array(
'description' => t('mailstation'),
'type' => 'varchar',
'length'=>10,
'not null' => TRUE,
'default' => '',
),
'college_school' => array(
'description' => t('college or school'),
'type' => 'varchar',
'length'=>50,
'not null' => TRUE,
'default' =>'',
),
'request_type' => array(
'description' => t('request type'),
'type' => 'varchar',
'length'=>20,
'not null' => TRUE,
'default' =>'',
),
'course_id' => array(
'description' => t('course id'),
'type' => 'varchar',
'length'=>9,
'not null' => TRUE,
'default' =>'',
),
'new_course_subject' => array(
'description' => t('new course subject'),
'type' => 'varchar',
'length'=>50,
'not null' => TRUE,
'default' =>'',
),
'new_course_cat_number' => array(
'description' => t('new course catalog number'),
'type' => 'varchar',
'length'=>50,
'not null' => TRUE,
'default' =>'',
),
'new_course_title' => array(
'description' => t('new course title'),
'type' => 'varchar',
'length'=>50,
'not null' => TRUE,
'default' =>'',
),
'new_course_units' => array(
'description' => t('new course units'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' =>0,
),
'former_course_subject' => array(
'description' => t('former course subject'),
'type' => 'varchar',
'length'=>50,
'not null' => TRUE,
'default' =>'',
),
'former_course_cat_number' => array(
'description' => t('former course catalog number'),
'type' => 'varchar',
'length'=>50,
'not null' => TRUE,
'default' =>'',
),
'former_course_title' => array(
'description' => t('former course title'),
'type' => 'varchar',
'length'=>50,
'not null' => TRUE,
'default' =>'',
),
'former_course_units' => array(
'description' => t('former course units'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' =>0,
),
'catalog_description' => array(
'description' => t('catalog description'),
'type'=>'varchar',
'length'=> 50,
'not null' => TRUE,
'default' => '',
),
),
'primary key' => array('nid'),
);
return $schema;
}
same problem
I am also encountering the same problem here... anybody help..?
found a solution
i think this might help...
http://www.nabble.com/schema-API----why-isn%27t-my-table-being-created--...
I have the same problem in
I have the same problem in d7.
I have the same problem too
I have the same problem too!
dont use hook_install and
dont use hook_install and hook_uninstall
here is my code for drupal 7
I have the same as you...
...but still doesn't work. I tried to uninstall the module, clear caches, etc but no answer, the table doesn't appear in the db. Any clue?
thanks
THE VERY LITTLE AGENCY
Can't help without code.
Can't help without code. Also, are you using D6 or D7?
Contact me to contract me for D7 -> D10/11 migrations.
d7, and here is the code
THE VERY LITTLE AGENCY
SOLVED IT
My problem was that accidentally I was working on the .install file with the module activated. Then I tried to uncheck it from the list, clear caches etc but obviously was not enough for the core to consider it renewed and didn't apply the changes in my .install file.
I deactivated the module, I went to modules and in the 'uninstall' tab clicked my module, and then, install it back and it worked. As simple as that.
THE VERY LITTLE AGENCY
That did the trick!!!
Thanks so much for posting your solution. I had been disabling and enabling my module like mad after updating hook_schema() and Drupal simply refused to create my table. After disabling the module, uninstalling it (via the modules page) and then then enabling it again my table was finally created. Huzaah!