function migrate()
{
    #----------------------------------------------------------------------
    # TODO: unescape the uris.
    #--- Leave if we've done this migration already.
    if (databaseTableExists('ResultsStatus')) {
        noticeBox(false, "This migration has already been applied.");
        return;
    }
    #--- ResultsStatus table: Create it.
    reportAction("ResultsStatus", "Create");
    dbCommand("\n    CREATE TABLE ResultsStatus (\n      id    VARCHAR(50) NOT NULL,\n      value VARCHAR(50) NOT NULL\n    )\n  ");
    #--- ResultsStatus table: Set migration number.
    reportAction("ResultsStatus", "Set migration number to 1");
    dbCommand("INSERT INTO ResultsStatus (id, value) VALUES ('migration', '1')");
    #--- Apply the migration changes.
    buildTableCompetitionsMedia();
    alterTableCompetitions();
    #--- PreRegs table: Create it.
    #--- UPDATE aux...
    #--- Yippie, we did it!
    noticeBox(true, "Migration completed.");
}
function migrate()
{
    #----------------------------------------------------------------------
    #--- Leave if we are not at migration n-1
    if (!databaseTableExists('ResultsStatus')) {
        noticeBox(false, "You need to apply migration 1 first.");
        return;
    }
    #--- Leave if we are already up-to-date
    $number = dbQuery("\n              SELECT value FROM  ResultsStatus\n              WHERE  id = 'migration'\n  ");
    $number = $number[0]['value'];
    if ($number != '1') {
        noticeBox(false, "Wrong version number : " . $number . ". Must be 1");
        return;
    }
    #--- ResultsStatus table: Update migration number.
    reportAction("ResultsStatus", "Set migration number to 2");
    dbCommand("\n    UPDATE   ResultsStatus\n      SET    value = '2'\n      WHERE  id = 'migration'\n  ");
    #--- Apply the migration changes.
    buildTableCompetitionsMedia();
    alterTableCompetitions();
    #--- Yippie, we did it!
    noticeBox(true, "Migration completed.");
}