コード例 #1
0
ファイル: test_uniquediffs.php プロジェクト: kitware/cdash
 public function testUniqueDiffsUpgrade()
 {
     require_once 'include/upgrade_functions.php';
     global $CDASH_DB_TYPE;
     $pdo = get_link_identifier()->getPdo();
     $tables = ['test_builderrordiff', 'test_configureerrordiff', 'test_testdiff'];
     foreach ($tables as $table) {
         // Create testing tables.
         if ($CDASH_DB_TYPE == 'pgsql') {
             $create_query = '
                 CREATE TABLE "' . $table . '" (
                         "buildid" integer NOT NULL,
                         "type" smallint NOT NULL,
                         "difference" integer NOT NULL
                         )';
         } else {
             // MySQL
             $create_query = "\n                    CREATE TABLE `{$table}` (\n                            `buildid` int(11) NOT NULL,\n                            `type` tinyint(4) NOT NULL,\n                            `difference` int(11) NOT NULL,\n                            KEY `buildid` (`buildid`),\n                            KEY `type` (`type`)\n                            )";
         }
         if (!$pdo->query($create_query)) {
             $this->fail("Error creating {$table}");
         }
         // Insert duplicate data into each.
         $stmt = $pdo->prepare("INSERT INTO {$table} (buildid, type, difference)\n                VALUES (?, 0, 1)");
         $stmt->execute([$this->BuildId]);
         $stmt = $pdo->prepare("INSERT INTO {$table} (buildid, type, difference)\n                VALUES (?, 0, 2)");
         $stmt->execute([$this->BuildId]);
         // Verify duplicate was inserted successfully.
         $this->checkRowCount($pdo, $table, 2);
     }
     // Run the upgrade function.
     AddUniqueConstraintToDiffTables(true);
     foreach ($tables as $table) {
         // Verify that each table only has one row.
         $this->checkRowCount($pdo, $table, 1);
         // Drop the testing tables.
         $pdo->query("DROP TABLE {$table}");
     }
 }
コード例 #2
0
ファイル: upgrade.php プロジェクト: kitware/cdash
        }
    }
    // Support for subproject path.
    AddTableField('subproject', 'path', 'varchar(512)', 'character varying(512)', '');
    // Remove the errorlog from the DB (we're all log files now).
    pdo_query('DROP TABLE IF EXISTS errorlog');
    // Option to pass label filters from index.php to test pages.
    AddTableField('project', 'sharelabelfilters', 'tinyint(1)', 'smallint', '0');
    // Summarize the number of dynamic analysis defects each build found.
    PopulateDynamicAnalysisSummaryTable();
    // Add index to buildupdate::revision in support of this filter.
    AddTableIndex('buildupdate', 'revision');
    // Store CTEST_CHANGE_ID in the build table.
    AddTableField('build', 'changeid', 'varchar(40)', 'character varying(40)', '');
    // Add unique constraints to the *diff tables.
    AddUniqueConstraintToDiffTables();
    // 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>';
    }