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

Contents of /contributions/modules/wishlist/wishlist.install

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


Revision 1.5 - (show annotations) (download) (as text)
Wed Jan 16 06:06:50 2008 UTC (22 months, 1 week ago) by smclewin
Branch: MAIN
CVS Tags: DRUPAL-6--2-3, DRUPAL-6--2-2, DRUPAL-6--2-1, HEAD
Branch point for: DRUPAL-6--2
Changes since 1.4: +16 -14 lines
File MIME type: text/x-php
Addressing schema deficiencies.  #205095
1 <?php
2 // $Id: wishlist.install,v 1.4 2007/11/25 03:34:04 smclewin Exp $
3
4
5
6
7 /**
8 * Update the wishlist purchased table to allow us to track when
9 * A given item was purchased.
10 */
11 function wishlist_update_2() {
12 $ret = array();
13
14 db_add_field($ret, 'wishlist_purchased', 'purch_date', array('type' => 'int', 'unsigned' => true, 'not null' => true, 'default' => 0));
15
16 // Update existing rows to have a date of today.
17 $sql = "UPDATE {wishlist_purchased} SET purch_date=%d WHERE purch_date=0";
18 $result = db_query($sql, time());
19 $ret[] = array('success' => $result !== FALSE, 'query' => check_plain($sql));
20
21 return $ret;
22 }
23
24
25 /**
26 * 4.6 to 4.7 update per http://drupal.org/node/22218#utf8_sql
27 */
28 function wishlist_update_1() {
29 return _system_update_utf8(array('wishlist', 'wishlist_purchased'));
30 }
31
32 /**
33 * Build out the necessary tables for the wishlist module
34 */
35 function wishlist_install() {
36 drupal_set_message('Installing wishlist');
37
38 drupal_install_schema('wishlist');
39 }
40
41 function wishlist_uninstall() {
42 drupal_uninstall_schema('wishlist');
43 }
44
45 /**
46 * @desc Defines the schema for the wishlist module's tables.
47 *
48 * Table wishlist holds the node specific fields.
49 * Table wishlist_purchased holds the purchase records for a node.
50 */
51 function wishlist_schema() {
52 $schema['wishlist'] = array(
53 'fields' => array(
54 'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => t('Foreign key to the node table.')),
55 'item_is_public' => array('type' => 'int', 'size' => 'tiny', 'not null' => true, 'default' => 1, 'description' => t('Is this item public, or is it maintained on the user\'s private list')),
56 'item_est_cost' => array('type' => 'int', 'not null' => FALSE, 'disp-width' => '11', 'description' => t('The estimated cost for the item')),
57 'item_url1' => array('type' => 'text', 'not null' => FALSE, 'description' => t('A URL from which the item can be purchased')),
58 'item_url2' => array('type' => 'text', 'not null' => FALSE, 'description' => t('A URL from which the item can be purchased')),
59 'item_quantity_requested' => array('type' => 'int', 'size' => 'small', 'not null' => true, 'default' => 1, 'description' => t('How many of this item does the user want?')),
60 'item_currency' => array('type' => 'varchar', 'length' => 4, 'not null' => true, 'default' => 'USD', 'description' => t('What currency is the estimated cost in')),
61 'item_priority' => array('type' => 'int', 'size' => 'tiny', 'default' => 3, 'not null' => FALSE, 'description' => t('How important is this item to the user?'))
62 ),
63 'primary key' => array('nid'),
64 'description' => t('Holds the details of a wishlist node'),
65 );
66
67 $schema['wishlist_purchased'] = array(
68 'fields' => array(
69 'wishlist_purch_wid' => array('type' => 'serial', 'not null' => true, 'description' => t('Unique ID for this purchase record')),
70 'wishlist_purch_nid' => array('type' => 'int', 'not null' => true, 'default' => 0, 'description' => t('Foreign key to the wishlist table and node table')),
71 'wishlist_purch_buyer_uid' => array('type' => 'int', 'not null' => true, 'default' => 0, 'description' => t('UID of the user that purchased the item')),
72 'wishlist_purch_quantity' => array('type' => 'int', 'size' => 'small', 'not null' => true, 'default' => 1, 'description' => t('How many this user purchased')),
73 'purch_date' => array('type' => 'int', 'unsigned' => true, 'not null' => true, 'default' => 0, 'description' => t('The date of the purchase')),
74 ),
75 'primary key' => array('wishlist_purch_wid'),
76 'description' => t('A record of an item purchased off of a wishlist'),
77 );
78
79 return $schema;
80 }
81
82
83

  ViewVC Help
Powered by ViewVC 1.1.2