schema api 'char' datatype not working ..

  1. <?php # vim: set filetype=php expandtab tabstop=2 shiftwidth=2 autoindent smartindent:
  2.  
  3. function balance_install() {
  4.   drupal_install_schema('balance');
  5. }
  6.  
  7. // user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT NULL, `amount` FLOAT DEFAULT NULL, `lid` FLOAT DEFAULT NULL, `status`' at line 3 query: CREATE TABLE web_balance ( `bid` INT unsigned NOT NULL auto_increment, `module` DEFAULT NULL, `amount` FLOAT DEFAULT NULL, `lid` FLOAT DEFAULT NULL, `status` TINYINT unsigned NOT NULL DEFAULT 0, PRIMARY KEY (bid) ) /*!40100 DEFAULT CHARACTER SET UTF8 */ in /c/projects/click_to_call/trunk/control_interface/includes/database.inc on line 509.
  8. // user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DEFAULT NULL, `started` DATETIME NOT NULL, `cancelled` DATETIME NOT NULL, `co' at line 7 query: CREATE TABLE web_balance_log ( `lid` INT unsigned NOT NULL auto_increment, `bid` INT unsigned NOT NULL, `type` TINYINT unsigned DEFAULT NULL, `amount` FLOAT DEFAULT NULL, `cid` INT unsigned DEFAULT NULL, `module` DEFAULT NULL, `started` DATETIME NOT NULL, `cancelled` DATETIME NOT NULL, `completed` DATETIME NOT NULL, `status` TINYINT DEFAULT NULL, PRIMARY KEY (bid, id) ) /*!40100 DEFAULT CHARACTER SET UTF8 */ in /c/projects/click_to_call/trunk/control_interface/includes/database.inc on line 509.
  9.  
  10.  
  11. function balance_schema() {
  12.   $schema['balance'] = array(
  13.     'fields' => array(
  14.       'bid'      => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
  15.       'module'  => array('type' => 'char', 'size' => 25), /* The module which created this balance entry .. */
  16.       'amount'    => array('type' => 'float'), /* The amount is kept under default currency */
  17.       'lid'    => array('type' => 'float'), /* Last billing log that is responsible for balance change .. */
  18.       'status' => array('type' => 'int', 'unsigned' => TRUE, 'size' => 'tiny', 'not null' => TRUE, 'default' => 0) /* 1-enabled, 0-disabled */
  19.     ),
  20.     'primary key' => array('bid'),
  21.   );
  22.   $schema["balance_log"] = array(
  23.     'fields' => array(
  24.       'lid'      => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
  25.       'bid'      => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
  26.       'type'  => array('type' => 'int', 'unsigned' => TRUE, 'size' => 'tiny'), /* if we are doing debit or credit .. */
  27.       'amount'    => array('type' => 'float'), /* The amount of money has been transferred */
  28.       'cid'    => array('type' => 'int', 'unsigned' => TRUE),
  29.       'module'  => array('type' => 'char', 'size' => 25), /* The module responsible for the billing log .. */
  30.       'started' => array('type' => 'datetime', 'not null' => TRUE), /* time when the transaction started .. */
  31.       'cancelled' => array('type' => 'datetime', 'not null' => TRUE), /* time when the transaction cancelled .. */
  32.       'completed' => array('type' => 'datetime', 'not null' => TRUE), /* time when the transaction completed .. */
  33.       'status' => array('type' => 'int', 'size' => 'tiny'), /* 1-completed, 2-cancelled, 3-locked etc .. */
  34.     ),
  35.     'primary key' => array('bid', 'id'),
  36.   );
  37.   $schema["currency"] = array(
  38.     'fields' => array(
  39.       'vid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)
  40.       ,'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)
  41.       ,'conversion_rate' => array('type' => 'float', 'default' => 1) /* conversion rate to the default currency */
  42.     ),
  43.     'primary key' => array('nid', 'vid')
  44.   );
  45.   return $schema;
  46. }
  47.  
  48. function balance_uninstall() {
  49. }