/[drupal]/contributions/modules/wishlist/wishlist.install
ViewVC logotype

Diff of /contributions/modules/wishlist/wishlist.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.3, Fri Jan 12 05:02:27 2007 UTC revision 1.4, Sun Nov 25 03:34:04 2007 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: wishlist.install,v 1.2 2006/12/26 19:32:19 smclewin Exp $  // $Id: wishlist.install,v 1.3 2007/01/12 05:02:27 smclewin Exp $
3    
4    
5    
# Line 10  Line 10 
10   */   */
11  function wishlist_update_2() {  function wishlist_update_2() {
12    $ret = array();    $ret = array();
13    switch ($GLOBALS['db_type']) {  
14      case 'mysqli':    db_add_field($ret, 'wishlist_purchased', 'purch_date', array('type' => 'int', 'unsigned' => true, 'not null' => true, 'default' => 0));
15      case 'mysql':  
16        $ret[] = update_sql("ALTER TABLE {wishlist_purchased} ADD `purch_date` int(11) unsigned NOT NULL default '0'");    // Update existing rows to have a date of today.
17      $sql = "UPDATE {wishlist_purchased} SET purch_date=%d WHERE purch_date=0";
18        $sql = "UPDATE {wishlist_purchased} SET purch_date=%d WHERE purch_date=0";    $result = db_query($sql, time());
19        $result = db_query($sql, time());    $ret[] = array('success' => $result !== FALSE, 'query' => check_plain($sql));
20        $ret[] = array('success' => $result !== FALSE, 'query' => check_plain($sql));  
     case 'pgsql':  
       return array('success' => FALSE, 'query' => t('Postgres not supported.  Please contribute and test the necessary SQL snippet to add the purch_date field.'));  
   }  
21    return $ret;    return $ret;
22  }  }
23    
# Line 38  function wishlist_update_1() { Line 35  function wishlist_update_1() {
35  function wishlist_install() {  function wishlist_install() {
36     drupal_set_message('Installing wishlist');     drupal_set_message('Installing wishlist');
37    
38     switch($GLOBALS['db_type']) {     drupal_install_schema('wishlist');
39        case 'mysql':  }
       case 'mysqli':  
          db_query("  
             CREATE TABLE {wishlist} (  
                     nid int(10) NOT NULL,  
                     item_is_public tinyint(4) NOT NULL default '1',  
                     item_est_cost int(11) default NULL,  
                     item_url1 text,  
                     item_url2 text,  
                     item_quantity_requested smallint(6) NOT NULL default '1',  
                     item_currency char(3) NOT NULL default 'USD',  
                     item_priority tinyint(4) default '3',  
                     PRIMARY KEY  (nid)  
             ) /*!40100 DEFAULT CHARACTER SET utf8 */;");  
           db_query("CREATE TABLE {wishlist_purchased} (  
                           wishlist_purch_wid int(10) NOT NULL auto_increment,  
                           wishlist_purch_nid int(10) NOT NULL default '0',  
                           wishlist_purch_buyer_uid int(10) NOT NULL default '0',  
                           wishlist_purch_quantity smallint(6) unsigned NOT NULL default '1',  
                           purch_date int(11) unsigned NOT NULL default '0',  
                           PRIMARY KEY  (wishlist_purch_wid)  
                         ) /*!40100 DEFAULT CHARACTER SET utf8 */;");  
           break;  
40    
41    function wishlist_uninstall() {
42        drupal_uninstall_schema('wishlist');
43    }
44    
45  /**  /**
46   * PGSQL support contributed by toddfries (http://drupal.org/user/39075)  * @desc Defines the schema for the wishlist module's tables.
47   *  *
48   * Note that I (wishlist module maintainer) do not run or test with PGSQL.  This port of  * Table wishlist holds the node specific fields.
49   * the original contribution from toddfries to the 4.7 install system was never  * Table wishlist_purchased holds the purchase records for a node.
50   * tested by me.  If you encounter an error, please submit a patch  */
51   * against the wishlist module.  function wishlist_schema() {
52   */      $schema['wishlist'] = array(
53        case 'pgsql':          'fields' => array(
54           db_query("CREATE TABLE {wishlist} (              'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
55                           nid serial,              'item_is_public' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 1),
56                           item_is_public smallint NOT NULL default '1',              'item_est_cost' => array('type' => 'int', 'default' => null),
57                           item_est_cost integer default NULL,              'item_url1' => array('type' => 'text'),
58                           item_url1 text,              'item_url2' => array('type' => 'text'),
59                           item_url2 text,              'item_quantity_requested' => array('type' => 'int', 'size' => 'small', 'not null' => true, 'default' => 1),
60                           item_quantity_requested smallint NOT NULL default '1',              'item_currency' => array('type' => 'varchar', 'length' => 4, 'not null' => true, 'default' => 'USD'),
61                           item_currency varchar(3) NOT NULL default 'USD',              'item_priority' => array('type' => 'int', 'size' => 'tiny', 'default' => 3)
62                           item_priority smallint default '3');");          ),
63            'primary key' => array('nid'),
64           db_query("CREATE TABLE {wishlist_purchased} (      );
65                           wishlist_purch_wid serial,  
66                           wishlist_purch_nid integer NOT NULL default '0',      $schema['wishlist_purchased'] = array(
67                           wishlist_purch_buyer_uid integer NOT NULL default '0',          'fields' => array(
68                           wishlist_purch_quantity smallint NOT NULL default '1',              'wishlist_purch_wid' => array('type' => 'serial', 'not null' => true),
69                           PRIMARY KEY  (wishlist_purch_wid));");              'wishlist_purch_nid' => array('type' => 'int', 'not null' => true, 'default' => 0),
70  // Postgres support known broken as new 'purch_date' field in v2 of the wishlist module is not present.              'wishlist_purch_buyer_uid' => array('type' => 'int', 'not null' => true, 'default' => 0),
71                  drupal_set_message('postgres support is incomplete and looking for help from an interested user who is willing to submit patches and test it.');              'wishlist_purch_quantity' => array('type' => 'int', 'size' => 'small', 'not null' => true, 'default' => 1),
72           break;              'purch_date' => array('type' => 'int', 'unsigned' => true, 'not null' => true, 'default' => 0),
73     }          ),
74            'primary key' => array('wishlist_purch_wid'),
75        );
76    
77        return $schema;
78  }  }
79    
80    
81    

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.2