/[drupal]/contributions/modules/ubercart/uc_roles/uc_roles.install
ViewVC logotype

Contents of /contributions/modules/ubercart/uc_roles/uc_roles.install

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


Revision 1.2 - (show annotations) (download) (as text)
Thu Jul 10 12:41:04 2008 UTC (16 months, 2 weeks ago) by islandusurper
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-6--2
Changes since 1.1: +81 -33 lines
File MIME type: text/x-php
Begin the Ubercart 6.x-2.x branch.
1 <?php
2 // $Id$
3
4 function uc_roles_install() {
5 switch ($GLOBALS['db_type']) {
6 case 'mysqli':
7 case 'mysql':
8 db_query("CREATE TABLE {uc_roles_products} (
9 pfid mediumint(9) NOT NULL,
10 nid int(10) NOT NULL,
11 model varchar(255) default NULL,
12 rid mediumint(11) NOT NULL,
13 duration smallint(4) default NULL,
14 granularity varchar(32) default NULL,
15 shippable BOOL NOT NULL,
16 by_quantity BOOL NOT NULL,
17 KEY pfid (pfid),
18 KEY nid (nid),
19 KEY model (model),
20 KEY rid (rid)
21 ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
22 db_query("CREATE TABLE {uc_roles_expirations} (
23 uid mediumint(11) NOT NULL,
24 rid mediumint(11) NOT NULL,
25 expiration int(11) NOT NULL,
26 notified tinyint(2) default NULL,
27 KEY uid (uid),
28 KEY rid (rid)
29 ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
30 break;
31 case 'pgsql':
32 db_query("CREATE TABLE {uc_roles_products} (
33 pfid integer NOT NULL,
34 nid integer NOT NULL,
35 model varchar(255) default NULL,
36 rid integer NOT NULL,
37 duration smallint default NULL,
38 granularity varchar(32) default NULL,
39 shippable boolean NOT NULL,
40 by_quantity boolean NOT NULL
41 );");
42 db_query("CREATE INDEX {uc_roles_products}_pfid ON {uc_roles_products} (pfid)");
43 db_query("CREATE INDEX {uc_roles_products}_nid ON {uc_roles_products} (nid)");
44 db_query("CREATE INDEX {uc_roles_products}_model ON {uc_roles_products} (model)");
45 db_query("CREATE INDEX {uc_roles_products}_rid ON {uc_roles_products} (rid)");
46 db_query("CREATE TABLE {uc_roles_expirations} (
47 uid integer NOT NULL,
48 rid integer NOT NULL,
49 expiration integer NOT NULL,
50 notified smallint default NULL
51 );");
52 db_query("CREATE INDEX {uc_roles_expirations}_uid ON {uc_roles_expirations} (uid)");
53 db_query("CREATE INDEX {uc_roles_expirations}_rid ON {uc_roles_expirations} (rid)");
54 break;
55 }
56 }
57
58 function uc_roles_uninstall() {
59 switch ($GLOBALS['db_type']) {
60 case 'mysqli':
61 case 'mysql':
62 db_query("DROP TABLE IF EXISTS {uc_roles_products}");
63 db_query("DROP TABLE IF EXISTS {uc_roles_expirations}");
64 break;
65 case 'pgsql':
66 db_query("DROP TABLE {uc_roles_products}");
67 db_query("DROP TABLE {uc_roles_expirations}");
68 break;
69 }
70 }
71
72 function uc_roles_update_1() {
73 $ret = array();
74
75 switch ($GLOBALS['db_type']) {
76 case 'mysql':
77 case 'mysqli':
78 $ret[] = update_sql("ALTER TABLE {uc_roles_products} CHANGE expiration duration SMALLINT( 4 ) NULL DEFAULT NULL");
79 $ret[] = update_sql("ALTER TABLE {uc_roles_products} CHANGE model model VARCHAR( 255 ) CHARACTER SET utf8 NULL");
80 break;
81 case 'pgsql':
82 break;
83 }
84
85 return $ret;
86 }
87
88 function uc_roles_update_2() {
89 $ret = array();
90
91 switch ($GLOBALS['db_type']) {
92 case 'mysql':
93 case 'mysqli':
94 $ret[] = update_sql("ALTER TABLE {uc_roles_products} ADD shippable BOOL NOT NULL");
95 break;
96 case 'pgsql':
97 break;
98 }
99
100 return $ret;
101 }
102
103 function uc_roles_update_3() {
104 $ret = array();
105
106 switch ($GLOBALS['db_type']) {
107 case 'mysql':
108 case 'mysqli':
109 $ret[] = update_sql("ALTER TABLE {uc_roles_products} ADD by_quantity BOOL NOT NULL");
110 break;
111 case 'pgsql':
112 $ret[] = update_sql("ALTER TABLE {uc_roles_products} ADD by_quantity boolean NOT NULL");
113 break;
114 }
115
116 return $ret;
117 }

  ViewVC Help
Powered by ViewVC 1.1.2