hook_install not creating a db table, what am I doing wrong?

stripped your speech - August 14, 2009 - 15:57

Here is the code I have in the install file, Drupal/MYSQL report no errors, yet nothing is created in my database.

function store_price_level_schema() {
$schema['store_price_level'] = array(
    'description' => t('Maps SKUs to price levels.'),
    'fields' => array(
  'plid' => array(
        'description' => 'The primary key',
        'type' => 'serial',
        'not null' => TRUE,
  ),
     'sku' => array(
        'description' => 'The item SKU',
        'type' => 'varchar',
'length' => '32',
'not null' => TRUE,
        'default' => '',
      ),
  'level' => array(
        'description' => 'The item price level',
        'type' => 'varchar',
'length' => '16',
'not null' => TRUE,
        'default' => '',
      ),
  'uofm' => array(
        'description' => 'The unit of measure',
        'type' => 'varchar',
'length' => '16',
'not null' => TRUE,
        'default' => '',
      ),
     'start_qty' => array(
        'description' => 'The start quantity',
        'type' => 'int',
'default' => 0,
'not null' => TRUE,
'unsigned' => TRUE,
      ),
  'end_qty' => array(
        'description' => 'The end quantity',
        'type' => 'int',
'default' => 0,
'not null' => TRUE,
'unsigned' => TRUE,
      ),
  'price' => array(
        'description' => 'The price',
        'type' => 'float',
'default' => 0,
'not null' => TRUE,
'unsigned' => TRUE,
      ),
    ),
    'primary key' => array('plid'),
  );
 
  return $schema;
}

/**
* Implementation of hook_install().
*/
function store_price_level_install() {
  drupal_install_schema('store_price_level');
}

If there is a typo I am not really seeing it. Am I missing something?

Take a look at the schema

ericduran - August 14, 2009 - 17:14

Take a look at the schema module. It might be able to help you out.

http://drupal.org/project/schema

Eric

I'm not sure I understand. I

stripped your speech - August 14, 2009 - 17:44

I'm not sure I understand. I see what this module does, but debugging why my new module isn't creating a table? I'm stuck.

Well, if you activated your

coreyp_1 - August 14, 2009 - 18:20

Well, if you activated your module *before* writing the install hook, then Drupal won't run the Install hook again... unless you uninstall the module first. That happens a lot when developing.

-Corey

- Corey

*facepalm* Thanks. Thought I

stripped your speech - August 14, 2009 - 18:37

*facepalm*

Thanks. Thought I was losing my mind there for a bit. All that exists is the install and an empty .module. I deleted the module from the test server, reloaded the Modules page and a record still existed in the system table for it. So I deleted the record, uploaded the module, enabled it and the table is now created. Thanks.

 
 

Drupal is a registered trademark of Dries Buytaert.