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

Contents of /contributions/modules/userpoints/userpoints.install

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


Revision 1.15 - (show annotations) (download) (as text)
Wed Mar 26 20:12:43 2008 UTC (20 months ago) by kbahey
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-6--1
Changes since 1.14: +177 -138 lines
File MIME type: text/x-php
#228478: by BTMash and t3r0: Port to Drupal 6.x
1 <?php
2 // $Id: userpoints.install,v 1.2.2.7.2.13 2008/01/31 03:53:12 kbahey Exp $
3
4 /**
5 * Implementation of hook_schema().
6 */
7 function userpoints_schema() {
8 $schema = array();
9 $schema['userpoints'] = array(
10 'description' => 'Holds the user points',
11 'fields' => array(
12 'pid' => array(
13 'description' => t('User ID'),
14 'type' => 'serial',
15 'not null' => TRUE,
16 ),
17 'uid' => array(
18 'description' => t('User ID'),
19 'type' => 'int',
20 'not null' => TRUE,
21 'default' => 0,
22 ),
23 'points' => array(
24 'description' => t('Current Points'),
25 'type' => 'int',
26 'not null' => TRUE,
27 'default' => 0,
28 ),
29 'max_points' => array(
30 'description' => t('Out of a maximum points'),
31 'type' => 'int',
32 'not null' => TRUE,
33 'default' => 0,
34 ),
35 'last_update' => array(
36 'description' => t('Timestamp'),
37 'type' => 'int',
38 'not null' => TRUE,
39 'default' => 0,
40 ),
41 'tid' => array(
42 'description' => t('Category ID'),
43 'type' => 'int',
44 'not null' => TRUE,
45 'default' => 0,
46 ),
47 ),
48 'primary key' => array('pid'),
49 'indexes' => array(
50 'last_update' => array('last_update'),
51 ),
52 );
53
54 $schema['userpoints_txn'] = array(
55 'description' => t('Userpoints Transactions'),
56 'fields' => array(
57 'txn_id' => array(
58 'description' => t('Transaction ID'),
59 'type' => 'serial',
60 'not null' => TRUE,
61 ),
62 'uid' => array(
63 'description' => t('User ID'),
64 'type' => 'int',
65 'not null' => TRUE,
66 'default' => 0,
67 ),
68 'approver_uid' => array(
69 'description' => t('Approving User ID'),
70 'type' => 'int',
71 'not null' => TRUE,
72 'default' => 0,
73 ),
74 'points' => array(
75 'description' => t('Points'),
76 'type' => 'int',
77 'not null' => TRUE,
78 'default' => 0,
79 ),
80 'time_stamp' => array(
81 'description' => t('Timestamp'),
82 'type' => 'int',
83 'not null' => TRUE,
84 'default' => 0,
85 ),
86 'status' => array(
87 'description' => t('Status'),
88 'type' => 'int',
89 'size' => 'tiny',
90 'not null' => TRUE,
91 'default' => 0,
92 ),
93 'description' => array(
94 'description' => t('Description'),
95 'type' => 'text',
96 ),
97 'reference' => array(
98 'description' => t('Reserved for module specific use'),
99 'type' => 'varchar',
100 'length' => 128,
101 ),
102 'expirydate' => array(
103 'description' => t('Expirydate'),
104 'type' => 'int',
105 'not null' => TRUE,
106 'default' => 0,
107 ),
108 'expired' => array(
109 'description' => t('User ID'),
110 'type' => 'int',
111 'size' => 'tiny',
112 'not null' => TRUE,
113 'default' => 0,
114 ),
115 'parent_txn_id' => array(
116 'description' => t('Parent Transaction ID'),
117 'type' => 'int',
118 'not null' => TRUE,
119 'default' => 0,
120 ),
121 'tid' => array(
122 'description' => t('Category ID'),
123 'type' => 'int',
124 'not null' => TRUE,
125 'default' => 0,
126 ),
127 'entity_id' => array(
128 'description' => t('ID of an entity in the Database'),
129 'type' => 'int',
130 'not null' => TRUE,
131 'default' => 0,
132 ),
133 'entity_type' => array(
134 'description' => t('Type of entity'),
135 'type' => 'varchar',
136 'length' => 32,
137 ),
138 'operation' => array(
139 'description' => t('Operation being carried out'),
140 'type' => 'varchar',
141 'length' => 32,
142 ),
143
144 ),
145 'primary key' => array('txn_id'),
146 'indexes' => array(
147 'operation' => array('operation'),
148 'reference' => array('reference'),
149 'status' => array('status'),
150 )
151 );
152 return $schema;
153 }
154
155 /**
156 * Install the initial schema.
157 */
158 function userpoints_install() {
159 drupal_install_schema('userpoints');
160 }
161
162 /**
163 * Implementation of hook_uninstall().
164 */
165 function userpoints_uninstall() {
166 drupal_uninstall_schema('userpoints');
167 db_query("DELETE FROM {variable} WHERE name like '%userpoints%'");
168
169 $vid = db_result(db_query("SELECT vid FROM {vocabulary} WHERE module='userpoints'"));
170 if ($vid) {
171 taxonomy_del_vocabulary($vid);
172 }
173 }
174
175 function userpoints_update_1() {
176 return _system_update_utf8(array('userpoints'));
177 }
178
179 function userpoints_update_2() {
180 $ret = array();
181 db_add_field($ret, 'userpoints', 'max_points', array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'lenght' => 10));
182 db_change_field($ret, 'userpoints', 'points', 'points', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'lenght' => 10));
183 return $ret;
184 }
185
186 function userpoints_update_3() {
187 $ret = array();
188 db_add_field($ret, 'userpoints_txn', 'description', array('type' => 'text'));
189 return $ret;
190 }
191
192 function userpoints_update_4() {
193 $ret = array();
194 db_change_field($ret, 'userpoints_txn', 'event', 'event', array('type' => 'varchar', 'lenght' => 32 ));
195 db_change_field($ret, 'userpoints_txn', 'status', 'status', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0 ));
196 return $ret;
197 }
198
199 function userpoints_update_5() {
200 $ret = array();
201 db_add_field($ret, 'userpoints_txn', 'reference', array('type' => 'varchar', 'lenght' => 128));
202 db_add_index($ret, 'userpoints_txn', 'reference', array('reference'));
203 return $ret;
204 }
205
206 function userpoints_update_6() {
207 $ret = array();
208 db_add_field($ret, 'userpoints_txn', 'expirydate', array('type' => 'int', 'lenght' => 11, 'not null' => true));
209 db_add_field($ret, 'userpoints_txn', 'expired', array('type' => 'int', 'lenght' => 1, 'not null' => true, 'size' => 'tiny'));
210 db_add_field($ret, 'userpoints_txn', 'parent_txn_id', array('type' => 'int'));
211 db_add_field($ret, 'userpoints_txn', 'tid', array('type' => 'int'));
212
213 db_drop_primary_key($ret, 'userpoints');
214
215 db_add_field($ret, 'userpoints', 'tid', array('type' => 'int'));
216 db_add_field($ret, 'userpoints', 'pid', array('type' => 'serial', 'not null' => true));
217 db_add_primary_key($ret, 'userpoints', 'pid');
218 return $ret;
219 }
220 function userpoints_update_7() {
221 $ret = array();
222 db_add_field($ret, 'userpoints_txn', 'entity_id', array('type' => 'int', 'lenght' => 11, 'not null' => true));
223 db_add_field($ret, 'userpoints_txn', 'entity_type', array('type' => 'varchar', 'lenght' => 32));
224 db_change_field($ret, 'userpoints_txn', 'event', 'operation', array('type' => 'varchar'));
225 return $ret;
226 }
227 function userpoints_update_8() {
228 $ret = array();
229 db_change_field($ret, 'userpoints_txn', 'tid', 'tid', array('type' => 'int', 'not null' => true, 'default' => 0, 'lenght' => 11));
230 db_change_field($ret, 'userpoints', 'tid', 'tid', array('type' => 'int', 'not null' => true, 'default' => 0, 'lenght' => 11));
231 return $ret;
232 }

  ViewVC Help
Powered by ViewVC 1.1.2