MDL-10107 Fixed the definition of message providers ... it now works through files...
[moodle.git] / lib / db / upgrade.php
CommitLineData
4e423cbf 1<?PHP //$Id$
2
3// This file keeps track of upgrades to Moodle.
4//
5// Sometimes, changes between versions involve
6// alterations to database structures and other
7// major things that may break installations.
8//
9// The upgrade function in this file will attempt
10// to perform all the necessary actions to upgrade
11// your older installtion to the current version.
12//
13// If there's something it cannot do itself, it
14// will tell you what you need to do.
15//
16// The commands in here will all be database-neutral,
b1f93b15 17// using the methods of database_manager class
4e423cbf 18
19
20function xmldb_main_upgrade($oldversion=0) {
f33e1ed4 21 global $CFG, $THEME, $USER, $DB;
4e423cbf 22
23 $result = true;
24
46d318bc 25 $dbman = $DB->get_manager(); // loads ddl manager and xmldb classes
f33e1ed4 26
1ea260d8 27 ////////////////////////////////////////
28 ///upgrade supported only from 1.9.x ///
29 ////////////////////////////////////////
da4aa3e4 30
a1f27717 31 if ($result && $oldversion < 2008030700) {
32
33 /// Define index contextid-lowerboundary (not unique) to be dropped form grade_letters
a8cb94f6 34 $table = new xmldb_table('grade_letters');
69b80cc2 35 $index = new xmldb_index('contextid-lowerboundary', XMLDB_INDEX_NOTUNIQUE, array('contextid', 'lowerboundary'));
a1f27717 36
37 /// Launch drop index contextid-lowerboundary
eee5d9bb 38 $dbman->drop_index($table, $index);
a1f27717 39
a1f27717 40 /// Define index contextid-lowerboundary-letter (unique) to be added to grade_letters
a8cb94f6 41 $table = new xmldb_table('grade_letters');
69b80cc2 42 $index = new xmldb_index('contextid-lowerboundary-letter', XMLDB_INDEX_UNIQUE, array('contextid', 'lowerboundary', 'letter'));
a1f27717 43
44 /// Launch add index contextid-lowerboundary-letter
eee5d9bb 45 $dbman->add_index($table, $index);
a1f27717 46
47 /// Main savepoint reached
0f77b186 48 upgrade_main_savepoint($result, 2008030700);
49 }
a1f27717 50
1ea260d8 51 if ($result && $oldversion < 2008050100) {
52 // Update courses that used weekscss to weeks
a8cb94f6 53 $result = $DB->set_field('course', 'format', 'weeks', array('format' => 'weekscss'));
1ea260d8 54 upgrade_main_savepoint($result, 2008050100);
55 }
56
0b51c247 57 if ($result && $oldversion < 2008050200) {
58 // remove unused config options
59 unset_config('statsrolesupgraded');
60 upgrade_main_savepoint($result, 2008050200);
61 }
62
994fbaab 63 if ($result && $oldversion < 2008050700) {
64 /// Fix minor problem caused by MDL-5482.
65 require_once($CFG->dirroot . '/question/upgrade.php');
66 $result = $result && question_fix_random_question_parents();
67 upgrade_main_savepoint($result, 2008050700);
68 }
69
ab37dc60 70 if ($result && $oldversion < 2008051200) {
71 // if guest role used as default user role unset it and force admin to choose new setting
72 if (!empty($CFG->defaultuserroleid)) {
910dd4dd 73 if ($role = $DB->get_record('role', array('id'=>$CFG->defaultuserroleid))) {
ab37dc60 74 if ($guestroles = get_roles_with_capability('moodle/legacy:guest', CAP_ALLOW)) {
75 if (isset($guestroles[$role->id])) {
76 set_config('defaultuserroleid', null);
77 notify('Guest role removed from "Default role for all users" setting, please select another role.', 'notifysuccess');
78 }
79 }
80 } else {
81 set_config('defaultuserroleid', null);
82 }
83 }
84 }
85
8b9cfac4 86 if ($result && $oldversion < 2008051201) {
87 notify('Increasing size of user idnumber field, this may take a while...', 'notifysuccess');
88
469dcbcc 89 /// Under MySQL and Postgres... detect old NULL contents and change them by correct empty string. MDL-14859
90 if ($CFG->dbfamily == 'mysql' || $CFG->dbfamily == 'postgres') {
eee5d9bb 91 $DB->execute("UPDATE {user} SET idnumber = '' WHERE idnumber IS NULL");
469dcbcc 92 }
93
8b9cfac4 94 /// Define index idnumber (not unique) to be dropped form user
a8cb94f6 95 $table = new xmldb_table('user');
69b80cc2 96 $index = new xmldb_index('idnumber', XMLDB_INDEX_NOTUNIQUE, array('idnumber'));
8b9cfac4 97
98 /// Launch drop index idnumber
f33e1ed4 99 if ($dbman->index_exists($table, $index)) {
eee5d9bb 100 $dbman->drop_index($table, $index);
8b9cfac4 101 }
102
103 /// Changing precision of field idnumber on table user to (255)
a8cb94f6 104 $table = new xmldb_table('user');
69b80cc2 105 $field = new xmldb_field('idnumber', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null, 'password');
8b9cfac4 106
107 /// Launch change of precision for field idnumber
eee5d9bb 108 $dbman->change_field_precision($table, $field);
8b9cfac4 109
110 /// Launch add index idnumber again
69b80cc2 111 $index = new xmldb_index('idnumber', XMLDB_INDEX_NOTUNIQUE, array('idnumber'));
eee5d9bb 112 $dbman->add_index($table, $index);
8b9cfac4 113
114 /// Main savepoint reached
115 upgrade_main_savepoint($result, 2008051201);
116 }
117
7ade55ad 118 if ($result && $oldversion < 2008051202) {
910dd4dd 119 $log_action = new object();
7ade55ad 120 $log_action->module = 'course';
121 $log_action->action = 'unenrol';
122 $log_action->mtable = 'course';
123 $log_action->field = 'fullname';
910dd4dd 124 if (!$DB->record_exists('log_display', array('action'=>'unenrol', 'module'=>'course'))) {
125 $result = $result && $DB->insert_record('log_display', $log_action);
7ade55ad 126 }
127 upgrade_main_savepoint($result, 2008051202);
128 }
129
fa162144 130 if ($result && $oldversion < 2008051203) {
131 $table = new xmldb_table('mnet_enrol_course');
132 $field = new xmldb_field('sortorder', XMLDB_TYPE_INTEGER, '10', true, true, null, false, false, 0);
eee5d9bb 133 $dbman->change_field_precision($table, $field);
fa162144 134 upgrade_main_savepoint($result, 2008051203);
135 }
136
38fb8190 137 if ($result && $oldversion < 2008063001) {
138 // table to be modified
139 $table = new xmldb_table('tag_instance');
140 // add field
141 $field = new xmldb_field('tiuserid');
142 if (!$dbman->field_exists($table, $field)) {
143 $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0, 'itemid');
144 $dbman->add_field($table, $field);
145 }
146 // modify index
147 $index = new xmldb_index('itemtype-itemid-tagid');
148 $index->set_attributes(XMLDB_INDEX_UNIQUE, array('itemtype', 'itemid', 'tagid'));
149 $dbman->drop_index($table, $index);
150 $index = new xmldb_index('itemtype-itemid-tagid-tiuserid');
151 $index->set_attributes(XMLDB_INDEX_UNIQUE, array('itemtype', 'itemid', 'tagid', 'tiuserid'));
152 $dbman->add_index($table, $index);
153
154 /// Main savepoint reached
155 upgrade_main_savepoint($result, 2008063001);
156 }
98978c2e 157 if ($result && $oldversion < 2008063002) {
158
159 /// Define table repository to be created
160 $table = new xmldb_table('repository');
161
162 /// Adding fields to table repository
163 $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
164 $table->add_field('repositoryname', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
165 $table->add_field('repositorytype', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
166 $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
167 $table->add_field('contextid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
168 $table->add_field('username', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
169 $table->add_field('password', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
170 $table->add_field('data1', XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, null);
171 $table->add_field('data2', XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, null);
172 $table->add_field('data3', XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, null);
173 $table->add_field('data4', XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, null);
174 $table->add_field('data5', XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, null);
175 $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
176 $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0');
177
178 /// Adding keys to table repository
179 $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
180
181 /// Conditionally launch create table for repository
182 if (!$dbman->table_exists($table)) {
183 $dbman->create_table($table);
184 }
38fb8190 185
98978c2e 186 /// Main savepoint reached
187 upgrade_main_savepoint($result, 2008063002);
188 }
38fb8190 189
a036d7f3 190 if ($result && $oldversion < 2008070300) {
191 $result = $DB->delete_records_select('role_names', $DB->sql_isempty('role_names', 'name', false, false));
192 upgrade_main_savepoint($result, 2008070300);
193 }
4e781c7b 194
fe074586 195 if ($result && $oldversion < 2008070700) {
196 if (isset($CFG->defaultuserroleid) and isset($CFG->guestroleid) and $CFG->defaultuserroleid == $CFG->guestroleid) {
197 // guest can not be selected in defaultuserroleid!
198 unset_config('defaultuserroleid');
199 }
200 upgrade_main_savepoint($result, 2008070700);
201 }
202
ac5efef6 203 if ($result && $oldversion < 2008070701) {
204
205 /// Define table portfolio_instance to be created
206 $table = new xmldb_table('portfolio_instance');
207
208 /// Adding fields to table portfolio_instance
209 $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
210 $table->add_field('plugin', XMLDB_TYPE_CHAR, '50', null, XMLDB_NOTNULL, null, null, null, null);
211 $table->add_field('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
212 $table->add_field('visible', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '1');
213
214 /// Adding keys to table portfolio_instance
215 $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
216
217 /// Conditionally launch create table for portfolio_instance
218 if (!$dbman->table_exists($table)) {
219 $dbman->create_table($table);
220 }
221 /// Define table portfolio_instance_config to be created
222 $table = new xmldb_table('portfolio_instance_config');
223
224 /// Adding fields to table portfolio_instance_config
225 $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
226 $table->add_field('instance', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
227 $table->add_field('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
228 $table->add_field('value', XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, null);
229
230 /// Adding keys to table portfolio_instance_config
231 $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
232 $table->add_key('instance', XMLDB_KEY_FOREIGN, array('instance'), 'portfolio_instance', array('id'));
233
234 /// Adding indexes to table portfolio_instance_config
235 $table->add_index('name', XMLDB_INDEX_NOTUNIQUE, array('name'));
236
237 /// Conditionally launch create table for portfolio_instance_config
238 if (!$dbman->table_exists($table)) {
239 $dbman->create_table($table);
240 }
241
242 /// Define table portfolio_instance_user to be created
243 $table = new xmldb_table('portfolio_instance_user');
244
245 /// Adding fields to table portfolio_instance_user
246 $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
247 $table->add_field('instance', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
248 $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
249 $table->add_field('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
250 $table->add_field('value', XMLDB_TYPE_TEXT, 'big', null, null, null, null, null, null);
251
252 /// Adding keys to table portfolio_instance_user
253 $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
254 $table->add_key('instancefk', XMLDB_KEY_FOREIGN, array('instance'), 'portfolio_instance', array('id'));
255 $table->add_key('userfk', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
256
257 /// Conditionally launch create table for portfolio_instance_user
258 if (!$dbman->table_exists($table)) {
259 $dbman->create_table($table);
260 }
261
262 /// Main savepoint reached
263 upgrade_main_savepoint($result, 2008070701);
264 }
3b120e46 265
266 if ($result && $oldversion < 2008072400) {
120b3758 267 /// Create the database tables for message_processors
f65b2dae 268 $table = new xmldb_table('message_processors');
269 $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
270 $table->add_field('name', XMLDB_TYPE_CHAR, '166', null, XMLDB_NOTNULL, null, null, null, null);
271 $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
3b120e46 272 $dbman->create_table($table);
273
3b120e46 274 /// delete old and create new fields
f65b2dae 275 $table = new xmldb_table('message');
276 $field = new xmldb_field('messagetype');
3b120e46 277 $dbman->drop_field($table, $field);
278
279 /// fields to rename
f65b2dae 280 $field = new xmldb_field('message');
281 $field->set_attributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, null);
3b120e46 282 $dbman->rename_field($table, $field, 'fullmessage');
f65b2dae 283 $field = new xmldb_field('format');
284 $field->set_attributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, null, null, null, null, '0', null);
3b120e46 285 $dbman->rename_field($table, $field, 'fullmessageformat');
286
287 /// new message fields
f65b2dae 288 $field = new xmldb_field('subject');
289 $field->set_attributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, null);
3b120e46 290 $dbman->add_field($table, $field);
f65b2dae 291 $field = new xmldb_field('fullmessagehtml');
292 $field->set_attributes(XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null, null, null);
3b120e46 293 $dbman->add_field($table, $field);
f65b2dae 294 $field = new xmldb_field('smallmessage');
295 $field->set_attributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, null);
3b120e46 296 $dbman->add_field($table, $field);
297
298
f65b2dae 299 $table = new xmldb_table('message_read');
300 $field = new xmldb_field('messagetype');
3b120e46 301 $dbman->drop_field($table, $field);
f65b2dae 302 $field = new xmldb_field('mailed');
3b120e46 303 $dbman->drop_field($table, $field);
304
305 /// fields to rename
f65b2dae 306 $field = new xmldb_field('message');
307 $field->set_attributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, null);
3b120e46 308 $dbman->rename_field($table, $field, 'fullmessage');
f65b2dae 309 $field = new xmldb_field('format');
310 $field->set_attributes(XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, null, null, null, null, '0', null);
3b120e46 311 $dbman->rename_field($table, $field, 'fullmessageformat');
312
313
314 /// new message fields
f65b2dae 315 $field = new xmldb_field('subject');
316 $field->set_attributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, null);
3b120e46 317 $dbman->add_field($table, $field);
f65b2dae 318 $field = new xmldb_field('fullmessagehtml');
319 $field->set_attributes(XMLDB_TYPE_TEXT, 'medium', null, null, null, null, null, null, null);
3b120e46 320 $dbman->add_field($table, $field);
f65b2dae 321 $field = new xmldb_field('smallmessage');
322 $field->set_attributes(XMLDB_TYPE_TEXT, 'small', null, null, null, null, null, null, null);
3b120e46 323 $dbman->add_field($table, $field);
324
325 /// new table
f65b2dae 326 $table = new xmldb_table('message_working');
327 $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
328 $table->add_field('unreadmessageid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
329 $table->add_field('processorid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
330 $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
3b120e46 331 $dbman->create_table($table);
332
333
334 upgrade_main_savepoint($result, 2008072400);
335 }
336
4e781c7b 337 if ($result && $oldversion < 2008072800) {
338
339 /// Define field enablecompletion to be added to course
340 $table = new xmldb_table('course');
341 $field = new xmldb_field('enablecompletion');
342 $field->set_attributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'defaultrole');
343
344 /// Launch add field enablecompletion
345 if(!$dbman->field_exists($table,$field)) {
346 $dbman->add_field($table, $field);
347 }
348
349 /// Define field completion to be added to course_modules
350 $table = new xmldb_table('course_modules');
351 $field = new xmldb_field('completion');
352 $field->set_attributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'groupmembersonly');
353
354 /// Launch add field completion
355 if(!$dbman->field_exists($table,$field)) {
356 $dbman->add_field($table, $field);
357 }
358
359 /// Define field completiongradeitemnumber to be added to course_modules
360 $field = new xmldb_field('completiongradeitemnumber');
361 $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, null, null, 'completion');
362
363 /// Launch add field completiongradeitemnumber
364 if(!$dbman->field_exists($table,$field)) {
365 $dbman->add_field($table, $field);
366 }
367
368 /// Define field completionview to be added to course_modules
369 $field = new xmldb_field('completionview');
370 $field->set_attributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'completiongradeitemnumber');
371
372 /// Launch add field completionview
373 if(!$dbman->field_exists($table,$field)) {
374 $dbman->add_field($table, $field);
375 }
376
377 /// Define field completionexpected to be added to course_modules
378 $field = new xmldb_field('completionexpected');
379 $field->set_attributes(XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'completionview');
380
381 /// Launch add field completionexpected
382 if(!$dbman->field_exists($table,$field)) {
383 $dbman->add_field($table, $field);
384 }
385
386 /// Define table course_modules_completion to be created
387 $table = new xmldb_table('course_modules_completion');
388 if(!$dbman->table_exists($table)) {
389
390 /// Adding fields to table course_modules_completion
1e0c56ea 391 $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
392 $table->add_field('coursemoduleid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
393 $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
394 $table->add_field('completionstate', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
395 $table->add_field('viewed', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, null, null, null, null, null);
396 $table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
4e781c7b 397
398 /// Adding keys to table course_modules_completion
1e0c56ea 399 $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
4e781c7b 400
401 /// Adding indexes to table course_modules_completion
1e0c56ea 402 $table->add_index('coursemoduleid', XMLDB_INDEX_NOTUNIQUE, array('coursemoduleid'));
403 $table->add_index('userid', XMLDB_INDEX_NOTUNIQUE, array('userid'));
4e781c7b 404
405 /// Launch create table for course_modules_completion
406 $dbman->create_table($table);
407 }
408
409 /// Main savepoint reached
410 upgrade_main_savepoint($result, 2008072800);
411 }
412
4ab16a09 413 if ($result && $oldversion < 2008073000) {
ac5efef6 414
4ab16a09 415 /// Define table portfolio_log to be created
416 $table = new xmldb_table('portfolio_log');
417
418 /// Adding fields to table portfolio_log
419 $table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
420 $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
421 $table->add_field('time', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
422 $table->add_field('portfolio', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, null);
423 $table->add_field('caller_class', XMLDB_TYPE_CHAR, '150', null, XMLDB_NOTNULL, null, null, null, null);
424 $table->add_field('caller_file', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
425 $table->add_field('caller_sha1', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null, null, null);
426
427 /// Adding keys to table portfolio_log
428 $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
429 $table->add_key('userfk', XMLDB_KEY_FOREIGN, array('userid'), 'user', array('id'));
430 $table->add_key('portfoliofk', XMLDB_KEY_FOREIGN, array('portfolio'), 'portfolio_instance', array('id'));
431
432 /// Conditionally launch create table for portfolio_log
433 if (!$dbman->table_exists($table)) {
434 $dbman->create_table($table);
435 }
436
437 /// Main savepoint reached
438 upgrade_main_savepoint($result, 2008073000);
439 }
120b3758 440
441 if ($result && $oldversion < 2008073104) {
442 /// Drop old table that might exist for some people
443 $table = new xmldb_table('message_providers');
444 if ($dbman->table_exists($table)) {
445 $dbman->drop_table($table);
446 }
447
448 /// Define table message_providers to be created
449 $table = new xmldb_table('message_providers');
450
451 /// Adding fields to table message_providers
452 $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
453 $table->add_field('name', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null, null, null);
454 $table->add_field('component', XMLDB_TYPE_CHAR, '200', null, XMLDB_NOTNULL, null, null, null, null);
455 $table->add_field('capability', XMLDB_TYPE_CHAR, '255', null, null, null, null, null, null);
456
457 /// Adding keys to table message_providers
458 $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
459
460 /// Adding indexes to table message_providers
461 $table->add_index('componentname', XMLDB_INDEX_UNIQUE, array('component', 'name'));
462
463 /// Create table for message_providers
464 $dbman->create_table($table);
465
466 upgrade_main_savepoint($result, 2008073104);
467 }
4ab16a09 468
f33e1ed4 469/*
470 * TODO:
eb636785 471 * drop adodb_logsql table and create a new general sql log table
f33e1ed4 472 *
473 */
474
ac9b0805 475 return $result;
4e423cbf 476}
271e6dec 477
478
4e423cbf 479?>