$project->setPhrictionSlug($name);
        $slug = $project->getPhrictionSlug();
        echo pht("Updating project #%d '%s' (%s)... ", $id, $name, $slug);
        try {
            queryfx($project->establishConnection('w'), 'UPDATE %T SET name = %s, phrictionSlug = %s WHERE id = %d', $project->getTableName(), $name, $slug, $project->getID());
            unset($update[$key]);
            echo pht('OKAY') . "\n";
        } catch (AphrontDuplicateKeyQueryException $ex) {
            echo pht('Failed, will retry.') . "\n";
        }
    }
    if (count($update) == $size) {
        throw new Exception(pht('Failed to make any progress while updating projects. Schema upgrade ' . 'has failed. Go manually fix your project names to be unique ' . '(they are probably ridiculous?) and then try again.'));
    }
}
$table->endReadLocking();
$table->saveTransaction();
echo pht('Done.') . "\n";
/**
 * Rename the project so that it has a unique slug, by appending (2), (3), etc.
 * to its name.
 */
function rename_project($project, $projects)
{
    $suffix = 2;
    while (true) {
        $new_name = $project->getName() . ' (' . $suffix . ')';
        $project->setPhrictionSlug($new_name);
        $new_slug = $project->getPhrictionSlug();
        $okay = true;
        foreach ($projects as $other) {