<commit_before><?php  //$Id$
//
// This file keeps track of upgrades to Moodle's
// backup/restore utility.
// 
// Sometimes, changes between versions involve 
// alterations to database structures and other 
// major things that may break installations.  
//
// The upgrade function in this file will attempt
// to perform all the necessary actions to upgrade
// your older installtion to the current version.
//
// If there's something it cannot do itself, it 
// will tell you what you need to do.
//
// Versions are defined by backup_version.php
//

function backup_upgrade($oldversion=0) {

    global $CFG;

    $result = true;

    if ($oldversion < 2006011600 and $result) {
        $result = execute_sql("DROP TABLE {$CFG->prefix}backup_files");
        if ($result) {
            $result = execute_sql("CREATE TABLE {$CFG->prefix}backup_files (
                          id SERIAL PRIMARY KEY,
                          backup_code integer NOT NULL default '0',
                          file_type varchar(10) NOT NULL default '',
                          path varchar(255) NOT NULL default '',
                          old_id integer default NULL,
                          new_id integer default NULL,
                          CONSTRAINT {$CFG->prefix}backup_files_uk UNIQUE (backup_code, file_type, path))");
        }
        if ($result) {
            $result = execute_sql("DROP TABLE {$CFG->prefix}backup_ids");
        }
        if ($result) {
            $result = execute_sql("CREATE TABLE {$CFG->prefix}backup_ids (
                          id SERIAL PRIMARY KEY,
                          backup_code integer NOT NULL default '0',
                          table_name varchar(30) NOT NULL default '',
                          old_id integer NOT NULL default '0',
                          new_id integer default NULL,
                          info text,
                          CONSTRAINT {$CFG->prefix}backup_ids_uk UNIQUE (backup_code, table_name, old_id))");
        }
    }

    if ($oldversion < 2006042801) {
        modify_database('', 'ALTER TABLE prefix_backup_log
            ALTER COLUMN "time" TYPE integer,
            ALTER COLUMN "time" SET DEFAULT 0,
            ALTER COLUMN laststarttime TYPE integer,
            ALTER COLUMN laststarttime SET DEFAULT 0,
            ALTER COLUMN courseid TYPE integer,
            ALTER COLUMN courseid SET DEFAULT 0');

        modify_database('', 'ALTER TABLE mdl_backup_courses
            ALTER COLUMN lastendtime TYPE integer,
            ALTER COLUMN lastendtime SET DEFAULT 0,
            ALTER COLUMN laststarttime TYPE integer,
            ALTER COLUMN laststarttime SET DEFAULT 0,
            ALTER COLUMN courseid TYPE integer,
            ALTER COLUMN courseid SET DEFAULT 0,
            ALTER COLUMN nextstarttime TYPE integer,
            ALTER COLUMN nextstarttime SET DEFAULT 0');

    }

    //Finally, return result
    return $result;

}

?><commit_msg>Bug #6147 - Upgrade from 1.5.x breaks with Postgres 7.4.x<commit_after><?php  //$Id$
//
// This file keeps track of upgrades to Moodle's
// backup/restore utility.
// 
// Sometimes, changes between versions involve 
// alterations to database structures and other 
// major things that may break installations.  
//
// The upgrade function in this file will attempt
// to perform all the necessary actions to upgrade
// your older installtion to the current version.
//
// If there's something it cannot do itself, it 
// will tell you what you need to do.
//
// Versions are defined by backup_version.php
//

function backup_upgrade($oldversion=0) {

    global $CFG;

    $result = true;

    if ($oldversion < 2006011600 and $result) {
        $result = execute_sql("DROP TABLE {$CFG->prefix}backup_files");
        if ($result) {
            $result = execute_sql("CREATE TABLE {$CFG->prefix}backup_files (
                          id SERIAL PRIMARY KEY,
                          backup_code integer NOT NULL default '0',
                          file_type varchar(10) NOT NULL default '',
                          path varchar(255) NOT NULL default '',
                          old_id integer default NULL,
                          new_id integer default NULL,
                          CONSTRAINT {$CFG->prefix}backup_files_uk UNIQUE (backup_code, file_type, path))");
        }
        if ($result) {
            $result = execute_sql("DROP TABLE {$CFG->prefix}backup_ids");
        }
        if ($result) {
            $result = execute_sql("CREATE TABLE {$CFG->prefix}backup_ids (
                          id SERIAL PRIMARY KEY,
                          backup_code integer NOT NULL default '0',
                          table_name varchar(30) NOT NULL default '',
                          old_id integer NOT NULL default '0',
                          new_id integer default NULL,
                          info text,
                          CONSTRAINT {$CFG->prefix}backup_ids_uk UNIQUE (backup_code, table_name, old_id))");
        }
    }

    if ($oldversion < 2006042801) {
        table_column('backup_log', 'time', 'time', 'integer', '', '', '0');
        table_column('backup_log', 'laststarttime', 'laststarttime', 'integer', '', '', '0');
        table_column('backup_log', 'courseid', 'courseid', 'integer', '', '', '0');

        table_column('backup_courses', 'lastendtime', 'lastendtime', 'integer', '', '', '0');
        table_column('backup_courses', 'laststarttime', 'laststarttime', 'integer', '', '', '0');
        table_column('backup_courses', 'courseid', 'courseid', 'integer', '', '', '0');
        table_column('backup_courses', 'nextstarttime', 'nextstarttime', 'integer', '', '', '0');
    }

    //Finally, return result
    return $result;

}

?>
{'fraction_non_alphanumeric': 0.10380803338549817, 'fraction_numerical': 0.014606155451225874, 'mean_word_length': 1.9618949536560246, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5359548', 'n_tokens_mistral': 1576, 'n_tokens_neox': 1496, 'n_words': 492}