/[drupal]/contributions/modules/media_mover/media_mover_api.install
ViewVC logotype

Contents of /contributions/modules/media_mover/media_mover_api.install

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


Revision 1.13 - (show annotations) (download) (as text)
Mon Apr 7 16:57:18 2008 UTC (19 months, 2 weeks ago) by bdragon
Branch: MAIN
CVS Tags: HEAD
Changes since 1.12: +10 -1 lines
File MIME type: text/x-php
Add a missing index.
1 <?php
2
3 /* $Id: media_mover_api.install,v 1.12 2008/02/27 21:42:00 bdragon Exp $ */
4
5 // media_mover.install
6
7 function media_mover_api_schema() {
8 $schema['media_mover_files'] = array(
9 'fields' => array(
10 'mmfid' => array(
11 'type' => 'serial',
12 'not null' => TRUE,
13 ),
14 'nid' => array(
15 'type' => 'int',
16 'not null' => FALSE,
17 ),
18 'fid' => array(
19 'type' => 'int',
20 'not null' => TRUE,
21 'default' => 0,
22 ),
23 'cid' => array(
24 'type' => 'int',
25 'not null' => FALSE,
26 ),
27 'harvest_module' => array(
28 'type' => 'varchar',
29 'length' => '255',
30 'not null' => FALSE,
31 ),
32 'harvest_action' => array(
33 'type' => 'varchar',
34 'length' => '255',
35 'not null' => FALSE,
36 ),
37 'harvest_file' => array(
38 'type' => 'varchar',
39 'length' => '255',
40 'not null' => FALSE,
41 ),
42 'process_module' => array(
43 'type' => 'varchar',
44 'length' => '255',
45 'not null' => FALSE,
46 ),
47 'process_action' => array(
48 'type' => 'varchar',
49 'length' => '255',
50 'not null' => FALSE,
51 ),
52 'process_file' => array(
53 'type' => 'varchar',
54 'length' => '255',
55 'not null' => FALSE,
56 ),
57 'storage_module' => array(
58 'type' => 'varchar',
59 'length' => '255',
60 'not null' => FALSE,
61 ),
62 'storage_action' => array(
63 'type' => 'varchar',
64 'length' => '255',
65 'not null' => FALSE,
66 ),
67 'storage_file' => array(
68 'type' => 'varchar',
69 'length' => '255',
70 'not null' => FALSE,
71 ),
72 'complete_module' => array(
73 'type' => 'varchar',
74 'length' => '225',
75 'not null' => FALSE,
76 ),
77 'complete_action' => array(
78 'type' => 'varchar',
79 'length' => '225',
80 'not null' => FALSE,
81 ),
82 'complete_file' => array(
83 'type' => 'varchar',
84 'length' => '225',
85 'not null' => FALSE,
86 ),
87 'url' => array(
88 'type' => 'varchar',
89 'length' => '255',
90 'not null' => TRUE,
91 'default' => '',
92 ),
93 'status' => array(
94 'type' => 'varchar',
95 'length' => '48',
96 'not null' => TRUE,
97 'default' => '',
98 ),
99 'date' => array(
100 'type' => 'int',
101 'not null' => FALSE,
102 ),
103 'data' => array(
104 'type' => 'blob',
105 'not null' => TRUE,
106 ),
107 ),
108 'primary key' => array('mmfid'),
109 'indexes' => array(
110 'fid' => array('fid'),
111 ),
112 );
113
114 $schema['media_mover_configurations'] = array(
115 'fields' => array(
116 'cid' => array(
117 'type' => 'int',
118 'not null' => TRUE,
119 'default' => 0,
120 ),
121 'verb' => array(
122 'type' => 'varchar',
123 'length' => '16',
124 'not null' => FALSE,
125 ),
126 'module' => array(
127 'type' => 'varchar',
128 'length' => '255',
129 'not null' => TRUE,
130 'default' => '',
131 ),
132 'action' => array(
133 'type' => 'varchar',
134 'length' => '255',
135 'not null' => TRUE,
136 'default' => '',
137 ),
138 'configuration' => array(
139 'type' => 'blob',
140 'not null' => TRUE,
141 'serialize' => TRUE,
142 ),
143 ),
144 'primary key' => array('cid', 'verb'),
145 );
146
147 $schema['media_mover_config_list'] = array(
148 'fields' => array(
149 'cid' => array(
150 'type' => 'serial',
151 'unsigned' => TRUE,
152 'not null' => TRUE,
153 //'default' => 0,
154 ),
155 'name' => array(
156 'type' => 'varchar',
157 'length' => '255',
158 'not null' => FALSE,
159 ),
160 'description' => array(
161 'type' => 'varchar',
162 'length' => '255',
163 'not null' => FALSE,
164 ),
165 'status' => array(
166 'type' => 'varchar',
167 'length' => '48',
168 'not null' => TRUE,
169 'default' => 'disabled',
170 ),
171 'start_time' => array(
172 'type' => 'int',
173 'not null' => TRUE,
174 'default' => 0,
175 ),
176 'last_start_time' => array(
177 'type' => 'int',
178 'not null' => TRUE,
179 'default' => 0,
180 ),
181 ),
182 'primary key' => array('cid'),
183 );
184
185 return $schema;
186 }
187
188 function media_mover_api_install() {
189
190 drupal_install_schema('media_mover_api');
191 }
192
193 /**
194 * Implementation of hook_uninstall().
195 */
196 function media_mover_api_uninstall() {
197 drupal_uninstall_schema('media_mover_api');
198 variable_del('mma_no_cron_run');
199 variable_del('mma_file_perm');
200 variable_del('mma_file_mask');
201 variable_del('mma_node_edit_file_show');
202 variable_del('mma_node_file_delete');
203 variable_del('mma_cron_notify');
204 variable_del('mma_cron_notify_email');
205 variable_del('mma_cron_notify_time');
206 }
207
208 /**
209 * addes a status col to the configuration table
210 */
211 function media_mover_api_update_1() {
212 $ret = array();
213 db_change_field($ret, 'media_mover_config_list', 'status', 'status', array(
214 'type' => 'varchar',
215 'length' => 48,
216 'not null' => TRUE,
217 'default' => 'disabled',
218 ));
219 return $ret;
220 }
221
222 /**
223 * adds data col to the files table
224 */
225 function media_mover_api_update_2() {
226 $ret = array();
227 db_add_field($ret, 'media_mover_files', 'data', array(
228 'type' => 'blob',
229 //'after' => 'status',
230 ));
231 return $ret;
232 }
233
234 /**
235 * Creates the file harvest comparison table
236 */
237 function media_mover_api_update_3() {
238 $ret = array();
239 db_add_field($ret, 'media_mover_config_list', 'start_time', array(
240 'type' => 'int',
241 'not null' => TRUE,
242 'default' => 0,
243 //'after' => 'status',
244 ));
245 db_add_field($ret, 'media_mover_config_list', 'last_start_time', array(
246 'type' => 'int',
247 'not null' => TRUE,
248 'default' => 0,
249 //'after' => 'start_time'
250 ));
251 return $ret;
252 }
253
254 /**
255 * adds data col to the files table
256 */
257 function media_mover_api_update_4() {
258 $ret = array();
259 db_add_field($ret, 'media_mover_files', 'mmfid', array(
260 'type' => 'int',
261 'not null' => FALSE,
262 'default' => NULL,
263 // after => first?
264 ));
265 db_drop_index($ret, 'media_mover_files', 'nid');
266 db_drop_primary_key($ret, 'media_mover_files');
267 return $ret;
268 }
269
270 /**
271 * increases the size of the file tables
272 */
273 function media_mover_api_update_5() {
274 $ret = array();
275 db_change_field($ret, 'media_mover_files', 'harvest_file', 'harvest_file', array(
276 'type' => 'varchar',
277 'length' => 255,
278 ));
279 db_change_field($ret, 'media_mover_files', 'process_file', 'process_file', array(
280 'type' => 'varchar',
281 'length' => 255,
282 ));
283 db_change_field($ret, 'media_mover_files', 'storage_file', 'storage_file', array(
284 'type' => 'varchar',
285 'length' => 255,
286 ));
287 return $ret;
288 }
289
290 /**
291 * add the completion stuff
292 */
293 function media_mover_api_update_6() {
294 $ret = array();
295 db_add_field($ret, 'media_mover_files', 'complete_file', array(
296 'type' => 'varchar',
297 'length' => 255,
298 'not null' => TRUE,
299 //'after' => 'storage_file',
300 ));
301 db_add_field($ret, 'media_mover_files', 'complete_action', array(
302 'type' => 'varchar',
303 'length' => 255,
304 'not null' => TRUE,
305 //'after' => 'storage_file',
306 ));
307 db_add_field($ret, 'media_mover_files', 'complete_module', array(
308 'type' => 'varchar',
309 'length' => 255,
310 'not null' => TRUE,
311 //'after' => 'storage_file',
312 ));
313 return $ret;
314 }
315
316 /**
317 * add dates for when files were harvested
318 */
319 function media_mover_api_update_9() {
320 $ret = array();
321 db_add_field($ret, 'media_mover_files', 'date', array(
322 'type' => 'int',
323 'not null' => FALSE,
324 'default' => 0, // @@@ Doesn't match schema!
325 //'after' => 'status',
326 ));
327
328 $ret[] = update_sql('UPDATE {media_mover_files} SET date = %d WHERE date = 0', time());
329 return $ret;
330 }
331
332 /**
333 * changes the names of modules to reflect the new module naming scheme
334 */
335 function media_mover_api_update_10() {
336 $ret = array();
337
338 $ret[] = update_sql("UPDATE {media_mover_files} SET harvest_module = '%s' WHERE harvest_module = '%s' AND harvest_action <> 1", 'mm_node', 'media_mover');
339 $ret[] = update_sql("UPDATE {media_mover_files} SET storage_module = '%s' WHERE storage_module = '%s' AND storage_action <> 1", 'mm_node', 'media_mover');
340 $ret[] = update_sql("UPDATE {media_mover_files} SET process_module = '%s' WHERE process_module = '%s' AND process_action <> 1", 'mm_node', 'media_mover');
341 $ret[] = update_sql("UPDATE {media_mover_files} SET storage_module = '%s' WHERE storage_module = '%s' AND storage_action <> 1", 'mm_node', 'media_mover');
342 $ret[] = update_sql("UPDATE {media_mover_configurations} SET module = '%s' WHERE module = '%s' AND action <> 1", 'mm_node', 'media_mover');
343 $ret[] = update_sql("UPDATE {media_mover_configurations} SET module = '%s' WHERE module = '%s' AND action = 1", 'media_mover_api', 'media_mover');
344
345 return $ret;
346 }
347
348 /**
349 * Drupal 6 updates.
350 */
351 function media_mover_api_update_6001() {
352 $ret = array();
353
354 // Add auto increment to {media_mover_files}.
355 db_drop_primary_key($ret, 'media_mover_files');
356 db_change_field($ret, 'media_mover_files', 'mmfid', 'mmfid', array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), array('primary key' => array('mmfid')));
357
358 // Ad auto increment to {media_mover_config_list}.
359 db_drop_primary_key($ret, 'media_mover_config_list');
360 db_change_field($ret, 'media_mover_config_list', 'cid', 'cid', array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE), array('primary key' => array('cid')));
361
362 // delete db_next_id("{media_mover_config_list}_cid") ?
363 // delete db_next_id("{media_mover_files}_mmfid") ?
364
365 // These didn't make any sense in the first place...
366 variable_del('mm_config_name');
367 variable_del('mm_config_descript');
368
369 // Verb is WAY too long.
370 db_change_field($ret, 'media_mover_configurations', 'verb', 'verb', array('type' => 'varchar', 'length' => '16', 'not null' => TRUE, 'default' => ''));
371
372 // Add a primary key.
373 db_add_primary_key($ret, 'media_mover_configurations', array('cid', 'verb'));
374
375 return $ret;
376 }
377
378 /**
379 * Add a missing index.
380 */
381 function media_mover_api_update_6002() {
382 $ret = array();
383 db_add_index($ret, 'media_mover_files', 'fid', array('fid'));
384 return $ret;
385 }
386
387 /**
388 * Add another missing index.
389 */
390 function media_mover_api_update_6003() {
391 $ret = array();
392 db_add_index($ret, 'media_mover_files', 'nid_cid', array('nid', 'cid'));
393 return $ret;
394 }

  ViewVC Help
Powered by ViewVC 1.1.2