Can anyone tell me what is wrong with this schema file? it just wont install the table in the database as it supposed to do

function uc_flatweightrate_schema() {
  $schema = array();

  $schema['uc_flatweightrate_products'] = array(
    'fields' => array(
      'vid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'mid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'base_rate' => array(
        'type' => 'numeric',
        'precision' => 16,
        'scale' => 5,
        'not null' => FALSE,
      ),
	    'additional_weight' => array(
        'type' => 'numeric',
        'precision' => 16,
        'scale' => 5,
        'not null' => FALSE,
      ),
	    'additional_rate' => array(
        'type' => 'numeric',
        'precision' => 16,
        'scale' => 5,
        'not null' => FALSE,
      ),
	    'base_weight' => array(
        'type' => 'numeric',
        'precision' => 16,
        'scale' => 5,
        'not null' => FALSE,
      ),
    ),
    'primary key' => array('vid', 'mid'),
  );

  $schema['uc_flatweightrate_methods'] = array(
    'fields' => array(
      'mid' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'title' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'label' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'base_rate' => array(
        'type' => 'numeric',
        'precision' => 16,
        'scale' => 5,
        'not null' => TRUE,
        'default' => 0.0,
      ),
      'additional_rate' => array(
        'type' => 'numeric',
        'precision' => 16,
        'scale' => 5,
        'not null' => TRUE,
        'default' => 0.0,
      ),
	  'base_weight' => array(
        'type' => 'numeric',
        'precision' => 16,
        'scale' => 5,
        'not null' => TRUE,
        'default' => 0.0,
      ),
	  'additional_weight' => array(
        'type' => 'numeric',
        'precision' => 16,
        'scale' => 5,
        'not null' => TRUE,
        'default' => 0.0,
      ),
    ),
    'primary key' => array('mid'),
  );

  return $schema;
}

/**
 * Implementation of hook_install().
 */
function uc_flatweightrate_install() {
  drupal_install_schema('uc_flatweightrate');
}

/**
 * Implementation of hook_uninstall().
 */
function uc_flatweightrate_uninstall() {
  drupal_uninstall_schema('uc_flatweightrate');
}

Comments

gpk’s picture

If the module is already installed then you need to uninstall it first to get it to run the installation routine.