upgrade.php 24.2 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
/**
 * This program is part of Mahara
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 *
 * @package    mahara
Penny Leach's avatar
Penny Leach committed
20
21
 * @subpackage core
 * @author     Penny Leach <penny@catalyst.net.nz>
22
23
24
25
26
27
28
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
 * @copyright  (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
 *
 */

defined('INTERNAL') || die();

29
30
require_once('template.php');

31
32
33
34
function xmldb_core_upgrade($oldversion=0) {

    $status = true;

Penny Leach's avatar
Penny Leach committed
35
36
37
38
39
40
41
42
43
44
    if ($oldversion < 2006121400) {

        set_field('community', 'jointype', 'open', 'jointype', 'anyone');
        $table = new XMLDBTable('community');
        $field = new XMLDBField('jointype');
        $field->setAttributes(XMLDB_TYPE_CHAR, 20, false, true, false, true, 
                              array('controlled', 'invite', 'request', 'open'), 'open');
        change_field_default($table, $field);
        change_field_enum($table, $field);
    }
45

46
47
48
49
50
51
52
53
54
55
    if ($oldversion < 2006121401) {
        $table = new XMLDBTable('usr');
        $field = new XMLDBField('expirymailsent');
        $field->setAttributes(XMLDB_TYPE_INTEGER, 1, false, true, false, null, null, 0);
        add_field($table, $field);
        $field = new XMLDBField('inactivemailsent');
        $field->setAttributes(XMLDB_TYPE_INTEGER, 1, false, true, false, null, null, 0);
        add_field($table, $field);
    }

Nigel McNie's avatar
Nigel McNie committed
56
57
58
59
60
61
62
63
64
    // Add cron jobs for authentication cleanup: partial registrations and account expiries
    if ($oldversion < 2006121500) {
        $registrations = new StdClass;
        $registrations->callfunction = 'auth_clean_partial_registrations';
        $registrations->minute = '0';
        $registrations->hour = '5';
        insert_record('cron', $registrations);

        $expiries = new StdClass;
65
66
67
        $expiries->callfunction = 'auth_handle_account_expiries';
        $expiries->minute = '10';
        $expiries->hour = '5';
Nigel McNie's avatar
Nigel McNie committed
68
69
70
        insert_record('cron', $expiries);
    }

71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
    // Merge the usr_suspension table with the usr table, and add a 'active' column and
    // various events and fields to do with this column
    if ($oldversion < 2006121800) {
        $table = new XMLDBTable('usr_suspension');
        drop_table($table);

        $table = new XMLDBTable('usr');

        $field = new XMLDBField('suspendedctime');
        $field->setAttributes(XMLDB_TYPE_DATETIME);
        add_field($table, $field);

        $field = new XMLDBField('suspendedreason');
        $field->setAttributes(XMLDB_TYPE_TEXT);
        add_field($table, $field);

        $field = new XMLDBField('suspendedcusr');
        $field->setAttributes(XMLDB_TYPE_INTEGER, 10, false, false, false);
        add_field($table, $field);

        $field = new XMLDBField('active');
        $field->setAttributes(XMLDB_TYPE_INTEGER, 1, false, true, false, null, null, 1);
        add_field($table, $field);
        set_field('usr', 'active', 1);

        $key = new XMLDBKey('sus_fk');
        $key->setAttributes(XMLDB_KEY_FOREIGN, array('suspendedcusr'), 'usr', array('id'));
        add_key($table, $key);

        $event = new StdClass;
        $event->name = 'unsuspenduser';
        insert_record('event_type', $event);
        $event->name = 'undeleteuser';
        insert_record('event_type', $event);
        $event->name = 'expireuser';
        insert_record('event_type', $event);
        $event->name = 'unexpireuser';
        insert_record('event_type', $event);
        $event->name = 'deactivateuser';
        insert_record('event_type', $event);
        $event->name = 'activateuser';
        insert_record('event_type', $event);

        $activecheck = new StdClass;
        $activecheck->plugin = 'internal';
        $activecheck->event = 'suspenduser';
        $activecheck->callfunction = 'update_active_flag';
        insert_record('auth_event_subscription', $activecheck);
        $activecheck->event = 'unsuspenduser';
        insert_record('auth_event_subscription', $activecheck);
        $activecheck->event = 'deleteuser';
        insert_record('auth_event_subscription', $activecheck);
        $activecheck->event = 'undeleteuser';
        insert_record('auth_event_subscription', $activecheck);
        $activecheck->event = 'expireuser';
        insert_record('auth_event_subscription', $activecheck);
        $activecheck->event = 'unexpireuser';
        insert_record('auth_event_subscription', $activecheck);
        $activecheck->event = 'deactivateuser';
        insert_record('auth_event_subscription', $activecheck);
        $activecheck->event = 'activateuser';
        insert_record('auth_event_subscription', $activecheck);

    }

Richard Mansfield's avatar
Richard Mansfield committed
136
137
138
139
140
141
142
143
144
145
146
147
    if ($oldversion < 2006122200) {
        // Creating usr_infectedupload table
        $table = new XMLDBTable('usr_infectedupload');

        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED,
                             XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
        $table->addFieldInfo('usr', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL);
        $table->addFieldInfo('time', XMLDB_TYPE_DATETIME, null, null, XMLDB_NOTNULL);

        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        $table->addKeyInfo('usrfk', XMLDB_KEY_FOREIGN, array('usr'), 'usr', array('id'));

148
        create_table($table);
Richard Mansfield's avatar
Richard Mansfield committed
149
150
    }

151
152
153
154
155
    if ($oldversion < 2007011200) {
        // Add path to file to the config table
        set_config('pathtofile', '/usr/bin/file');
    }

156
157
158
159
160
161
162
163
    if ($oldversion < 2007011500) {
        // Add the 'profileicon' field to the usr table
        $table = new XMLDBTable('usr');
        $field = new XMLDBField('profileicon');
        $field->setAttributes(XMLDB_TYPE_INTEGER, 10, false, false, false);
        add_field($table, $field);
    }

164
165
166
167
168
169
170
171
172
173
    if ($oldversion < 2007011600) {
        // Add the 'quota' and 'quotaused' fields to the usr table
        $table = new XMLDBTable('usr');
        $field = new XMLDBField('quota');
        $field->setAttributes(XMLDB_TYPE_INTEGER, 10, false, false, false);
        add_field($table, $field);
        $field = new XMLDBField('quotaused');
        $field->setAttributes(XMLDB_TYPE_INTEGER, 10, false, true, null, null, null, 0);
        add_field($table, $field);

174
        execute_sql('UPDATE {usr} SET quota=10485760');
175
176
    }

177
178
179
180
181
182
183
184
185
    if ($oldversion < 2007012300) {
        // fix up a broken cron entry...
        set_field('cron', 'minute', '0', 'callfunction', 'rebuild_artefact_parent_cache_complete');
        $c = new StdClass;
        $c->callfunction = 'activity_process_queue';
        $c->minute = '*/5';
        insert_record('cron', $c);
    }

186
187
188
189
190
191
192
193
    if ($oldversion < 2007012301) {
        $at = new StdClass;
        $at->name = 'viewaccess';
        $at->admin = 0;
        $at->delay = 1;
        insert_record('activity_type', $at);
    }

194
195
    if ($oldversion < 2007012500) {
        $table = new XMLDBTable('usr_watchlist_artefact');
196
        $field = new XMLDBField('deleted');
197
198
199
200
        $field->setAttributes(XMLDB_TYPE_INTEGER, 1, false, true, false, false, false, 0);
        add_field($table, $field);
    }

201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
    if ($oldversion < 2007020300) {
        // artefact_tag table
        $table = new XMLDBTable('artefact_tag');
        $table->addFieldInfo('artefact', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL);
        $table->addKeyInfo('artefactfk', XMLDB_KEY_FOREIGN, array('artefact'), 'artefact', array('id'));
        $table->addFieldInfo('tag', XMLDB_TYPE_CHAR, '128', null, XMLDB_NOTNULL);
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('artefact', 'tag'));
        create_table($table);

        // view_tag table
        $table = new XMLDBTable('view_tag');
        $table->addFieldInfo('view', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL);
        $table->addKeyInfo('viewfk', XMLDB_KEY_FOREIGN, array('view'), 'view', array('id'));
        $table->addFieldInfo('tag', XMLDB_TYPE_CHAR, '128', null, XMLDB_NOTNULL);
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('view', 'tag'));
        create_table($table);
    }
218
219
220
221
    if ($oldversion < 2007020500) {
        insert_record('event_type', (object)array('name' => 'saveartefact'));
        insert_record('event_type', (object)array('name' => 'deleteartefact'));
    }
222

223
224
225
226
227
    if ($oldversion < 2007021600) {
        $template = template_parse('gallery');
        upgrade_template('gallery', $template);
    }

Martyn Smith's avatar
Martyn Smith committed
228
229
230
231
232
    if ($oldversion < 2007021900) {
        insert_record('event_type', (object)array('name' => 'saveview'));
        insert_record('event_type', (object)array('name' => 'deleteview'));
    }

233
234
235
236
237
    if ($oldversion < 2007021902) {
        $template = template_parse('filelist');
        upgrade_template('filelist', $template);
    }

238
    if ($oldversion < 2007021903) {
239
        execute_sql("UPDATE {artefact}
240
241
242
243
            SET container = 1
            WHERE artefacttype = 'blog'");
    }

244
245
246
247
248
    if ($oldversion < 2007021905) {
        $template = template_parse('blogandprofile');
        upgrade_template('blogandprofile', $template);
    }

249
250
    if ($oldversion < 2007042500) {
        // migrate everything we had to change to  make mysql happy
251
252
253
254
255
256
257
258
259
260
261
262
        execute_sql("ALTER TABLE {cron} DROP CONSTRAINT {cron_cal_pk}"); // can't drop primary keys using xmldb...
        execute_sql("ALTER TABLE {cron} ADD CONSTRAINT {cron_id_pk} PRIMARY KEY (id)"); // or add them!
        execute_sql("ALTER TABLE {cron} ADD CONSTRAINT {cron_cal_uix} UNIQUE (callfunction)");
        execute_sql("ALTER TABLE {community} ALTER COLUMN name TYPE varchar (128)");
        execute_sql("ALTER TABLE {usr_activity_preference} ALTER COLUMN method TYPE varchar(255)");
        execute_sql("ALTER TABLE {template_category} ALTER COLUMN name TYPE varchar(128)");
        execute_sql("ALTER TABLE {template_category} ALTER COLUMN parent TYPE varchar(128)");
        execute_sql("ALTER TABLE {template} ALTER COLUMN name TYPE varchar(128)");
        execute_sql("ALTER TABLE {template} ALTER COLUMN category TYPE varchar(128)");
        execute_sql("ALTER TABLE {view} ALTER COLUMN template TYPE varchar(128)");
        execute_sql("ALTER TABLE {view_access} ALTER COLUMN accesstype SET DEFAULT 'public'");
        execute_sql("ALTER TABLE {usr} ALTER COLUMN email TYPE varchar(255)");
263
264
    }

265
    // everything up to here was pre mysql support.
266
267

    if ($oldversion < 2007062000) {
268
        if (!get_record('config', 'field', 'lang')) {
269
            execute_sql("INSERT INTO {config} (field, value) VALUES ('lang', (SELECT value FROM {config} WHERE field = 'language'))");
270
        }
271
272
273
274
275
276
277
278
279
280
281
282
283
        delete_records('config', 'field', 'language');
    }

    if ($oldversion < 2007062900) {
        // application table
        $table = new XMLDBTable('application');
        $table->addFieldInfo('name', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL);
        $table->addFieldInfo('displayname', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL);
        $table->addFieldInfo('xmlrpcserverurl', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL);
        $table->addFieldInfo('ssolandurl', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL);
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('name'));
        create_table($table);

284
        $table = new XMLDBTable('auth_installed');
Donal McMullan's avatar
Donal McMullan committed
285
286
287
        //$field = new XMLDBField('name');
        //$field->setAttributes(XMLDB_TYPE_CHAR, 100, null, true, null, null, null);
        //change_field_precision($table, $field);
288
        
289
        $field = new XMLDBField('requires_config');
290
        $field->setAttributes(XMLDB_TYPE_INTEGER, 1, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0);
291
292
        add_field($table, $field);

293
        $field = new XMLDBField('requires_parent');
294
        $field->setAttributes(XMLDB_TYPE_INTEGER, 1, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0);
295
296
        add_field($table, $field);

297
298
299
        $table = new XMLDBTable('auth_instance');
        $table->addFieldInfo('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE);
        $table->addFieldInfo('instancename', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL);
300
        $table->addFieldInfo('priority', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0);
301
302
303
304
        $table->addFieldInfo('institution', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL);
        $table->addFieldInfo('authname', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL);
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('id'));
        create_table($table);
305

306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
        $key   = new XMLDBKey("authnamefk");
        $key->setAttributes(XMLDB_KEY_FOREIGN, array('authname'), 'auth_installed', array('name'));
        add_key($table, $key);
        $key   = new XMLDBKey("institutionfk");
        $key->setAttributes(XMLDB_KEY_FOREIGN, array('institution'), 'institution', array('name'));
        add_key($table, $key);

        $table = new XMLDBTable('auth_instance_config');
        $table->addFieldInfo('instance', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL);
        $table->addFieldInfo('field', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL);
        $table->addFieldInfo('value', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL);
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('instance','field'));
        create_table($table);

        $key   = new XMLDBKey("instancefk");
        $key->setAttributes(XMLDB_KEY_FOREIGN, array('instance'), 'auth_instance', array('id'));
        add_key($table, $key);

        $table = new XMLDBTable('host');
        $table->addFieldInfo('wwwroot', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL);
        $table->addFieldInfo('name', XMLDB_TYPE_CHAR, '80', null, XMLDB_NOTNULL);
        $table->addFieldInfo('institution', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL);
        $table->addFieldInfo('ipaddress', XMLDB_TYPE_CHAR, '39', null, XMLDB_NOTNULL);
        $table->addFieldInfo('portno', XMLDB_TYPE_INTEGER, '3', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 80);
        $table->addFieldInfo('appname', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL);
331
        $table->addFieldInfo('publickey', XMLDB_TYPE_TEXT, null, null, XMLDB_NOTNULL, null, null, null, '');
332
        $table->addFieldInfo('publickeyexpires', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL);
333
334
        $table->addFieldInfo('deleted', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0);
        $table->addFieldInfo('lastconnecttime', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 0);
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('wwwroot'));
        create_table($table);

        $key   = new XMLDBKey("appnamefk");
        $key->setAttributes(XMLDB_KEY_FOREIGN, array('appname'), 'application', array('name'));
        add_key($table, $key);

        $key   = new XMLDBKey("institutionfk");
        $key->setAttributes(XMLDB_KEY_FOREIGN, array('institution'), 'institution', array('name'));
        add_key($table, $key);

        $table = new XMLDBTable('institution');
        $key   = new XMLDBKey("pluginfk");
        $key->setAttributes(XMLDB_KEY_FOREIGN, array('authplugin'), 'auth_installed', array('name'));
        drop_key($table, $key);

        $field = new XMLDBField('authplugin');
        $field->setAttributes(XMLDB_TYPE_CHAR, 255, null, XMLDB_NOTNULL, null, null, null, '');
        drop_field($table, $field);

        $table = new XMLDBTable('sso_session');
        $table->addFieldInfo('userid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL);
        $table->addFieldInfo('instanceid', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL);
        $table->addFieldInfo('username', XMLDB_TYPE_CHAR, '30', null, XMLDB_NOTNULL);
        $table->addFieldInfo('useragent', XMLDB_TYPE_CHAR, '40', null, XMLDB_NOTNULL);
        $table->addFieldInfo('token', XMLDB_TYPE_CHAR, '40', null, XMLDB_NOTNULL);
        $table->addFieldInfo('confirmtimeout', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL);
        $table->addFieldInfo('expires', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL);
        $table->addFieldInfo('sessionid', XMLDB_TYPE_CHAR, '40', null, XMLDB_NOTNULL);
        $table->addKeyInfo('primary', XMLDB_KEY_PRIMARY, array('userid','instanceid'));
        create_table($table);

367
        $table = new XMLDBTable('usr');
368
369
370
371
        $field = new XMLDBField('authinstance');
        $field->setAttributes(XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, 1);
        add_field($table, $field);
        $index = new XMLDBIndex('usernameuk');
372
373
374
375
376
377
378
        $index->setAttributes(XMLDB_INDEX_UNIQUE, array('username', 'institution'));
        drop_index($table, $index);

        $index = new XMLDBIndex("usernameuk");
        $index->setAttributes(XMLDB_INDEX_UNIQUE, array('username', 'authinstance'));
        add_index($table, $index);

379
        $field = new XMLDBField('sessionid');
380
        $field->setAttributes(XMLDB_TYPE_CHAR, 32, null, null, null, null, null, '');
381
        add_field($table, $field);
382

383
384
385
        $field = new XMLDBField('lastauthinstance');
        $field->setAttributes(XMLDB_TYPE_INTEGER, 10, XMLDB_UNSIGNED);
        add_field($table, $field);
386

387
388
389
        $key   = new XMLDBKey("lastauthinstancefk");
        $key->setAttributes(XMLDB_KEY_FOREIGN, array('lastauthinstance'), 'auth_instance', array('id'));
        add_key($table, $key);
Donal McMullan's avatar
Donal McMullan committed
390
391

        $record = new stdClass();
392
393
394
395
396
397
398
399
400
401
402
403
404

        $record->name            = 'mahara';
        $record->displayname     = 'Mahara';
        $record->xmlrpcserverurl = '/api/xmlrpc/server.php';
        $record->ssolandurl      = '/auth/xmlrpc/land.php';
        insert_record('application',$record);

        $record->name            = 'moodle';
        $record->displayname     = 'Moodle';
        $record->xmlrpcserverurl = '/mnet/xmlrpc/server.php';
        $record->ssolandurl      = '/auth/mnet/land.php';
        insert_record('application',$record);

405
    }
406
407
408
409
410

    if ($oldversion < 2008080700) {
        // Drop DEFAULT '' from many columns that should not have had them
        // *nigel looks angrily at xmldb
        execute_sql('
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
            ALTER TABLE {notification_cron} ALTER COLUMN plugin DROP DEFAULT;
            ALTER TABLE {notification_cron} ALTER COLUMN callfunction DROP DEFAULT;
            ALTER TABLE {view_tag} ALTER COLUMN tag DROP DEFAULT;
            ALTER TABLE {site_content} ALTER COLUMN name DROP DEFAULT;
            ALTER TABLE {search_installed} ALTER COLUMN name DROP DEFAULT;
            ALTER TABLE {usr_registration} ALTER COLUMN salt DROP DEFAULT;
            ALTER TABLE {usr_registration} ALTER COLUMN "password" DROP DEFAULT;
            ALTER TABLE {usr_registration} ALTER COLUMN username DROP DEFAULT;
            ALTER TABLE {usr_registration} ALTER COLUMN "key" DROP DEFAULT;
            ALTER TABLE {usr_registration} ALTER COLUMN institution DROP DEFAULT;
            ALTER TABLE {auth_config} ALTER COLUMN plugin DROP DEFAULT;
            ALTER TABLE {auth_config} ALTER COLUMN field DROP DEFAULT;
            ALTER TABLE {artefact_cron} ALTER COLUMN plugin DROP DEFAULT;
            ALTER TABLE {artefact_cron} ALTER COLUMN callfunction DROP DEFAULT;
            ALTER TABLE {notification_event_subscription} ALTER COLUMN plugin DROP DEFAULT;
            ALTER TABLE {notification_event_subscription} ALTER COLUMN callfunction DROP DEFAULT;
            ALTER TABLE {notification_event_subscription} ALTER COLUMN event DROP DEFAULT;
            ALTER TABLE {notification_internal_activity} ALTER COLUMN "type" DROP DEFAULT;
            ALTER TABLE {activity_type} ALTER COLUMN name DROP DEFAULT;
            ALTER TABLE {auth_event_subscription} ALTER COLUMN plugin DROP DEFAULT;
            ALTER TABLE {auth_event_subscription} ALTER COLUMN callfunction DROP DEFAULT;
            ALTER TABLE {auth_event_subscription} ALTER COLUMN event DROP DEFAULT;
            ALTER TABLE {search_config} ALTER COLUMN plugin DROP DEFAULT;
            ALTER TABLE {search_config} ALTER COLUMN field DROP DEFAULT;
            ALTER TABLE {cron} ALTER COLUMN callfunction DROP DEFAULT;
            ALTER TABLE {artefact_tag} ALTER COLUMN tag DROP DEFAULT;
            ALTER TABLE {artefact_config} ALTER COLUMN plugin DROP DEFAULT;
            ALTER TABLE {artefact_config} ALTER COLUMN field DROP DEFAULT;
            ALTER TABLE {institution} ALTER COLUMN name DROP DEFAULT;
            ALTER TABLE {institution} ALTER COLUMN displayname DROP DEFAULT;
            ALTER TABLE {auth_instance_config} ALTER COLUMN field DROP DEFAULT;
            ALTER TABLE {notification_installed} ALTER COLUMN name DROP DEFAULT;
            ALTER TABLE {auth_installed} ALTER COLUMN name DROP DEFAULT;
            ALTER TABLE {artefact} ALTER COLUMN artefacttype DROP DEFAULT;
            ALTER TABLE {artefact_installed_type} ALTER COLUMN plugin DROP DEFAULT;
            ALTER TABLE {artefact_installed_type} ALTER COLUMN name DROP DEFAULT;
            ALTER TABLE {event_type} ALTER COLUMN name DROP DEFAULT;
            ALTER TABLE {usr_account_preference} ALTER COLUMN field DROP DEFAULT;
            ALTER TABLE {activity_queue} ALTER COLUMN "type" DROP DEFAULT;
            ALTER TABLE {notification_config} ALTER COLUMN plugin DROP DEFAULT;
            ALTER TABLE {notification_config} ALTER COLUMN field DROP DEFAULT;
            ALTER TABLE {artefact_installed} ALTER COLUMN name DROP DEFAULT;
            ALTER TABLE {notification_emaildigest_queue} ALTER COLUMN "type" DROP DEFAULT;
            ALTER TABLE {sso_session} ALTER COLUMN useragent DROP DEFAULT;
            ALTER TABLE {sso_session} ALTER COLUMN username DROP DEFAULT;
            ALTER TABLE {sso_session} ALTER COLUMN sessionid DROP DEFAULT;
            ALTER TABLE {sso_session} ALTER COLUMN token DROP DEFAULT;
            ALTER TABLE {search_event_subscription} ALTER COLUMN plugin DROP DEFAULT;
            ALTER TABLE {search_event_subscription} ALTER COLUMN callfunction DROP DEFAULT;
            ALTER TABLE {search_event_subscription} ALTER COLUMN event DROP DEFAULT;
            ALTER TABLE {usr} ALTER COLUMN "password" DROP DEFAULT;
            ALTER TABLE {usr} ALTER COLUMN username DROP DEFAULT;
            ALTER TABLE {application} ALTER COLUMN xmlrpcserverurl DROP DEFAULT;
            ALTER TABLE {application} ALTER COLUMN ssolandurl DROP DEFAULT;
            ALTER TABLE {application} ALTER COLUMN name DROP DEFAULT;
            ALTER TABLE {application} ALTER COLUMN displayname DROP DEFAULT;
            ALTER TABLE {institution_locked_profile_field} ALTER COLUMN name DROP DEFAULT;
            ALTER TABLE {institution_locked_profile_field} ALTER COLUMN profilefield DROP DEFAULT;
            ALTER TABLE {usr_password_request} ALTER COLUMN "key" DROP DEFAULT;
            ALTER TABLE {search_cron} ALTER COLUMN plugin DROP DEFAULT;
            ALTER TABLE {search_cron} ALTER COLUMN callfunction DROP DEFAULT;
            ALTER TABLE {auth_instance} ALTER COLUMN instancename DROP DEFAULT;
            ALTER TABLE {auth_instance} ALTER COLUMN authname DROP DEFAULT;
            ALTER TABLE {auth_instance} ALTER COLUMN institution DROP DEFAULT;
            ALTER TABLE {artefact_event_subscription} ALTER COLUMN plugin DROP DEFAULT;
            ALTER TABLE {artefact_event_subscription} ALTER COLUMN callfunction DROP DEFAULT;
            ALTER TABLE {artefact_event_subscription} ALTER COLUMN event DROP DEFAULT;
            ALTER TABLE {host} ALTER COLUMN wwwroot DROP DEFAULT;
            ALTER TABLE {host} ALTER COLUMN institution DROP DEFAULT;
            ALTER TABLE {usr_activity_preference} ALTER COLUMN activity DROP DEFAULT;
            ALTER TABLE {config} ALTER COLUMN field DROP DEFAULT;
            ALTER TABLE {auth_cron} ALTER COLUMN plugin DROP DEFAULT;
            ALTER TABLE {auth_cron} ALTER COLUMN callfunction DROP DEFAULT;
484
485
        ');
    }
486
    
487
488
489
490
491
492
493
494
495
496
497
498
    if ($oldversion < 2007081700) {
        // Remove groups from the system
        $table = new XMLDBTable('view_access_group');
        drop_table($table);

        $table = new XMLDBTable('usr_group_member');
        drop_table($table);

        $table = new XMLDBTable('usr_group');
        drop_table($table);
    }

499
500
501
502
    return $status;

}
?>