Skip to content

Commit

Permalink
MDL-23106 streamlined ext services table creation
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Jul 6, 2010
1 parent a32799a commit f688216
Showing 1 changed file with 3 additions and 37 deletions.
40 changes: 3 additions & 37 deletions lib/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2189,18 +2189,6 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2009090800);
}

if ($oldversion < 2009100601) {
// drop all previous tables defined during the dev phase
$dropold = array('external_services_users', 'external_services_functions', 'external_services', 'external_functions');
foreach ($dropold as $tablename) {
$table = new xmldb_table($tablename);
if ($dbman->table_exists($table)) {
$dbman->drop_table($table);
}
}
upgrade_main_savepoint(true, 2009100601);
}

if ($oldversion < 2009100602) {
/// Define table external_functions to be created
$table = new xmldb_table('external_functions');
Expand All @@ -2227,7 +2215,7 @@ function xmldb_main_upgrade($oldversion) {
}

if ($oldversion < 2009100603) {
/// Define table external_services to be created
/// Define table external_services to be created
$table = new xmldb_table('external_services');

/// Adding fields to table external_services
Expand All @@ -2237,6 +2225,8 @@ function xmldb_main_upgrade($oldversion) {
$table->add_field('requiredcapability', XMLDB_TYPE_CHAR, '150', null, null, null, null);
$table->add_field('restrictedusers', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
$table->add_field('component', XMLDB_TYPE_CHAR, '100', null, null, null, null);
$table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null);
$table->add_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null);

/// Adding keys to table external_services
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
Expand Down Expand Up @@ -2431,30 +2421,6 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2009110400);
}

if ($oldversion < 2009110605) {

/// Define field timecreated to be added to external_services
$table = new xmldb_table('external_services');
$field = new xmldb_field('timecreated', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'component');

/// Conditionally launch add field timecreated
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}

/// Define field timemodified to be added to external_services
$table = new xmldb_table('external_services');
$field = new xmldb_field('timemodified', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, null, null, null, 'timecreated');

/// Conditionally launch add field timemodified
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}

/// Main savepoint reached
upgrade_main_savepoint(true, 2009110605);
}

if ($oldversion < 2009112400) {
if (empty($CFG->passwordsaltmain)) {
$subject = get_string('check_passwordsaltmain_name', 'report_security');
Expand Down

0 comments on commit f688216

Please sign in to comment.