Fix for schema api 'char' datatype not working ..

  1. <?php
  2. # vim: set filetype=php expandtab tabstop=2 shiftwidth=2 autoindent smartindent:
  3. function balance_install()
  4. {
  5.   drupal_install_schema('balance');
  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. function balance_schema()
  10. {
  11.   $schema['balance'] = array (
  12.     'fields' => array (
  13.       'bid' => array (
  14.         'type' => 'serial',
  15.         'unsigned' => TRUE,
  16.         'not null' => TRUE
  17.       ),
  18.       'module' => array (
  19.         'type' => 'char',
  20.         'size' => 25
  21.       ), /* The module which created this balance entry .. */
  22.       'amount' => array (
  23.         'type' => 'float'
  24.       ), /* The amount is kept under default currency */
  25.       'lid' => array (
  26.         'type' => 'float'
  27.       ), /* Last billing log that is responsible for balance change .. */
  28.       'status' => array (
  29.         'type' => 'int',
  30.         'unsigned' => TRUE,
  31.         'size' => 'tiny',
  32.         'not null' => TRUE,
  33.         'default' => 0
  34.       ) /* 1-enabled, 0-disabled */
  35.      
  36.     ),
  37.     'primary key' => array (
  38.       'bid'
  39.     ),
  40.    
  41.   );
  42.   $schema["balance_log"] = array (
  43.     'fields' => array (
  44.       'lid' => array (
  45.         'type' => 'serial',
  46.         'unsigned' => TRUE,
  47.         'not null' => TRUE
  48.       ),
  49.       'bid' => array (
  50.         'type' => 'int',
  51.         'unsigned' => TRUE,
  52.         'not null' => TRUE
  53.       ),
  54.       'type' => array (
  55.         'type' => 'int',
  56.         'unsigned' => TRUE,
  57.         'size' => 'tiny'
  58.       ), /* if we are doing debit or credit .. */
  59.       'amount' => array (
  60.         'type' => 'float'
  61.       ), /* The amount of money has been transferred */
  62.       'cid' => array (
  63.         'type' => 'int',
  64.         'unsigned' => TRUE
  65.       ),
  66.       'module' => array (
  67.         'type' => 'char',
  68.         'size' => 25
  69.       ), /* The module responsible for the billing log .. */
  70.       'started' => array (
  71.         'type' => 'datetime',
  72.         'not null' => TRUE
  73.       ), /* time when the transaction started .. */
  74.       'cancelled' => array (
  75.         'type' => 'datetime',
  76.         'not null' => TRUE
  77.       ), /* time when the transaction cancelled .. */
  78.       'completed' => array (
  79.         'type' => 'datetime',
  80.         'not null' => TRUE
  81.       ), /* time when the transaction completed .. */
  82.       'status' => array (
  83.         'type' => 'int',
  84.         'size' => 'tiny'
  85.       ), /* 1-completed, 2-cancelled, 3-locked etc .. */
  86.      
  87.     ),
  88.     'primary key' => array (
  89.       'bid',
  90.       'id'
  91.     ),
  92.    
  93.   );
  94.   $schema["currency"] = array (
  95.     'fields' => array (
  96.       'vid' => array (
  97.         'type' => 'int',
  98.         'unsigned' => TRUE,
  99.         'not null' => TRUE,
  100.         'default' => 0
  101.       ),
  102.       'nid' => array (
  103.         'type' => 'int',
  104.         'unsigned' => TRUE,
  105.         'not null' => TRUE,
  106.         'default' => 0
  107.       ),
  108.       'conversion_rate' => array (
  109.         'type' => 'float',
  110.         'default' => 1
  111.       ) /* conversion rate to the default currency */
  112.      
  113.     ),
  114.     'primary key' => array (
  115.       'nid',
  116.       'vid'
  117.     )
  118.   );
  119.   return $schema;
  120. }
  121. function balance_uninstall()
  122. {
  123. }