2014-05-22 20:19:03 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
$project_table = new PhabricatorProject();
|
|
|
|
$table_name = $project_table->getTableName();
|
|
|
|
$conn_w = $project_table->establishConnection('w');
|
|
|
|
$slug_table_name = id(new PhabricatorProjectSlug())->getTableName();
|
2016-12-14 23:05:37 +01:00
|
|
|
$time = PhabricatorTime::getNow();
|
2014-05-22 20:19:03 +02:00
|
|
|
|
2016-12-14 23:05:37 +01:00
|
|
|
echo pht('Migrating projects to slugs...')."\n";
|
2014-05-22 20:19:03 +02:00
|
|
|
foreach (new LiskMigrationIterator($project_table) as $project) {
|
|
|
|
$id = $project->getID();
|
|
|
|
|
2015-05-22 09:27:56 +02:00
|
|
|
echo pht('Migrating project %d...', $id)."\n";
|
2016-12-14 23:05:37 +01:00
|
|
|
|
|
|
|
$slug_text = PhabricatorSlug::normalizeProjectSlug($project->getName());
|
2014-05-22 20:19:03 +02:00
|
|
|
$slug = id(new PhabricatorProjectSlug())
|
2016-12-14 23:05:37 +01:00
|
|
|
->loadOneWhere('slug = %s', $slug_text);
|
|
|
|
|
2014-05-22 20:19:03 +02:00
|
|
|
if ($slug) {
|
2015-05-22 09:27:56 +02:00
|
|
|
echo pht('Already migrated %d... Continuing.', $id)."\n";
|
2014-05-22 20:19:03 +02:00
|
|
|
continue;
|
|
|
|
}
|
2016-12-14 23:05:37 +01:00
|
|
|
|
2014-05-22 20:19:03 +02:00
|
|
|
queryfx(
|
|
|
|
$conn_w,
|
|
|
|
'INSERT INTO %T (projectPHID, slug, dateCreated, dateModified) '.
|
|
|
|
'VALUES (%s, %s, %d, %d)',
|
|
|
|
$slug_table_name,
|
|
|
|
$project->getPHID(),
|
2016-12-14 23:05:37 +01:00
|
|
|
$slug_text,
|
2014-05-22 20:19:03 +02:00
|
|
|
$time,
|
|
|
|
$time);
|
2015-05-22 09:27:56 +02:00
|
|
|
echo pht('Migrated %d.', $id)."\n";
|
2014-05-22 20:19:03 +02:00
|
|
|
}
|
|
|
|
|
2015-05-22 09:27:56 +02:00
|
|
|
echo pht('Done.')."\n";
|