1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-29 17:00:59 +01:00
phorge-phorge/resources/sql/autopatches/20140521.projectslug.2.mig.php
epriestley 3d8d98bd8d Probably (?) fix two very old project slug migrations
Summary: Fixes T12020. These callsites to `getPhrictionSlug()` were missed when that method was removed. They're very old (early 2014, late 2011).

Test Plan:
These are tricky to test because the migrations are so ancient, but `bin/storage upgrade --force --apply phabricator:20140521.projectslug.2.mig.php` gave me //plausible// results.

The other migration is so ancient that it can't apply to a modern database so I'm just kind of winging that one. We probably have essentially no installs which will ever apply it again, though.

Reviewers: chad, avivey

Reviewed By: avivey

Maniphest Tasks: T12020

Differential Revision: https://secure.phabricator.com/D17060
2016-12-14 14:14:21 -08:00

36 lines
982 B
PHP

<?php
$project_table = new PhabricatorProject();
$table_name = $project_table->getTableName();
$conn_w = $project_table->establishConnection('w');
$slug_table_name = id(new PhabricatorProjectSlug())->getTableName();
$time = PhabricatorTime::getNow();
echo pht('Migrating projects to slugs...')."\n";
foreach (new LiskMigrationIterator($project_table) as $project) {
$id = $project->getID();
echo pht('Migrating project %d...', $id)."\n";
$slug_text = PhabricatorSlug::normalizeProjectSlug($project->getName());
$slug = id(new PhabricatorProjectSlug())
->loadOneWhere('slug = %s', $slug_text);
if ($slug) {
echo pht('Already migrated %d... Continuing.', $id)."\n";
continue;
}
queryfx(
$conn_w,
'INSERT INTO %T (projectPHID, slug, dateCreated, dateModified) '.
'VALUES (%s, %s, %d, %d)',
$slug_table_name,
$project->getPHID(),
$slug_text,
$time,
$time);
echo pht('Migrated %d.', $id)."\n";
}
echo pht('Done.')."\n";