예제 #1
0
파일: upgrade.php 프로젝트: rpshaw/CDash
    AddTableField('build', 'parentid', 'int(11)', 'int', '0');
    AddTableIndex('build', 'parentid');
    // Cache configure results similar to build & test
    AddTableField('build', 'configureerrors', 'smallint(6)', 'smallint', '-1');
    AddTableField('build', 'configurewarnings', 'smallint(6)', 'smallint', '-1');
    // Add new multi-column index to build table.
    // This improves the rendering speed of overview.php.
    $multi_index = array("projectid", "parentid", "starttime");
    AddTableIndex("build", $multi_index);
    // Support for dynamic BuildGroups.
    AddTableField('buildgroup', 'type', 'varchar(20)', 'character varying(20)', 'Daily');
    AddTableField('build2grouprule', 'parentgroupid', 'int(11)', 'bigint', '0');
    // Support for pull request notifications.
    AddTableField('build', 'notified', 'tinyint(1)', 'smallint', '0');
    // Better caching of buildfailures.
    UpgradeBuildFailureTable('buildfailure', 'buildfailuredetails');
    // Set the database version
    setVersion();
    // Put that the upgrade is done in the log
    add_log("Upgrade done.", "upgrade-2-4");
    return;
}
// When adding new tables they should be added to the SQL installation file
// and here as well
if ($Upgrade) {
    // check if the backup directory is writable
    if (!is_writable($CDASH_BACKUP_DIRECTORY)) {
        $xml .= "<backupwritable>0</backupwritable>";
    } else {
        $xml .= "<backupwritable>1</backupwritable>";
    }
예제 #2
0
 function testBuildFailureDetailsUpgrade()
 {
     require_once dirname(__FILE__) . '/cdash_test_case.php';
     require_once 'cdash/common.php';
     require_once 'cdash/pdo.php';
     $retval = 0;
     $old_table = "testbuildfailure";
     $new_table = "testdetails";
     global $CDASH_DB_TYPE;
     if ($CDASH_DB_TYPE == 'pgsql') {
         $create_old_query = '
     CREATE TABLE "' . $old_table . '" (
       "id" bigserial NOT NULL,
       "buildid" bigint NOT NULL,
       "type" smallint NOT NULL,
       "workingdirectory" character varying(512) NOT NULL,
       "stdoutput" text NOT NULL,
       "stderror" text NOT NULL,
       "exitcondition" character varying(255) NOT NULL,
       "language" character varying(64) NOT NULL,
       "targetname" character varying(255) NOT NULL,
       "outputfile" character varying(512) NOT NULL,
       "outputtype" character varying(255) NOT NULL,
       "sourcefile" character varying(512) NOT NULL,
       "crc32" bigint DEFAULT \'0\' NOT NULL,
       "newstatus" smallint DEFAULT \'0\' NOT NULL,
       PRIMARY KEY ("id")
     )';
         $create_new_query = '
     CREATE TABLE "' . $new_table . '" (
       "id" bigserial NOT NULL,
       "type" smallint NOT NULL,
       "stdoutput" text NOT NULL,
       "stderror" text NOT NULL,
       "exitcondition" character varying(255) NOT NULL,
       "language" character varying(64) NOT NULL,
       "targetname" character varying(255) NOT NULL,
       "outputfile" character varying(512) NOT NULL,
       "outputtype" character varying(255) NOT NULL,
       "crc32" bigint DEFAULT \'0\' NOT NULL,
       PRIMARY KEY ("id")
     )';
     } else {
         // MySQL
         $create_old_query = "\n        CREATE TABLE `{$old_table}` (\n          `id` bigint(20) NOT NULL auto_increment,\n          `buildid` bigint(20) NOT NULL,\n          `type` tinyint(4) NOT NULL,\n          `workingdirectory` varchar(512) NOT NULL,\n          `stdoutput` mediumtext NOT NULL,\n          `stderror` mediumtext NOT NULL,\n          `exitcondition` varchar(255) NOT NULL,\n          `language` varchar(64) NOT NULL,\n          `targetname` varchar(255) NOT NULL,\n          `outputfile` varchar(512) NOT NULL,\n          `outputtype` varchar(255) NOT NULL,\n          `sourcefile` varchar(512) NOT NULL,\n          `crc32` bigint(20) NOT NULL default '0',\n          `newstatus` tinyint(4) NOT NULL default '0',\n          PRIMARY KEY  (`id`)\n        )";
         $create_new_query = "\n        CREATE TABLE `{$new_table}` (\n          `id` bigint(20) NOT NULL auto_increment,\n          `type` tinyint(4) NOT NULL,\n          `stdoutput` mediumtext NOT NULL,\n          `stderror` mediumtext NOT NULL,\n          `exitcondition` varchar(255) NOT NULL,\n          `language` varchar(64) NOT NULL,\n          `targetname` varchar(255) NOT NULL,\n          `outputfile` varchar(512) NOT NULL,\n          `outputtype` varchar(255) NOT NULL,\n          `crc32` bigint(20) NOT NULL default '0',\n          PRIMARY KEY  (`id`)\n        )";
     }
     // Create testing tables.
     if (!pdo_query($create_old_query)) {
         $this->fail("pdo_query returned false");
         $retval = 1;
     }
     if (!pdo_query($create_new_query)) {
         $this->fail("pdo_query returned false");
         $retval = 1;
     }
     // Insert two identical buildfailures into the old table.
     $insert_query = "\n      INSERT INTO {$old_table}\n        (buildid, type, workingdirectory, stdoutput, stderror, exitcondition,\n         language, targetname, outputfile, outputtype, sourcefile, crc32,\n         newstatus)\n      VALUES\n        (1, 1, '/tmp/', 'this is stdout', 'this is stderror', '0',\n         'C', 'foo', 'foo.o', 'object file', 'foo.c', '1234',\n         '0')";
     if (!pdo_query($insert_query)) {
         $this->fail("pdo_query returned false");
         $retval = 1;
     }
     if (!pdo_query($insert_query)) {
         $this->fail("pdo_query returned false");
         $retval = 1;
     }
     // Run the upgrade function.
     UpgradeBuildFailureTable($old_table, $new_table);
     // Verify that we now have two buildfailures and one buildfailuredetails.
     $count_query = "\n      SELECT COUNT(DISTINCT id) AS numfails,\n             COUNT(DISTINCT detailsid) AS numdetails\n      FROM {$old_table}";
     $count_results = pdo_single_row_query($count_query);
     if ($count_results['numfails'] != 2) {
         $this->fail("Expected 2 buildfailures, found " . $count_results['numfails']);
         $retval = 1;
     }
     if ($count_results['numdetails'] != 1) {
         $this->fail("Expected 1 buildfailuredetails, found " . $count_results['numdetails']);
         $retval = 1;
     }
     // Drop the testing tables.
     pdo_query("DROP TABLE {$old_table}");
     pdo_query("DROP TABLE {$new_table}");
     if ($retval == 0) {
         $this->pass("Passed");
     }
     return $retval;
 }